From 0cb0577083344cabbd7ea415396133398c1a7ec6 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Sun, 24 Dec 2017 00:51:28 -0600 Subject: [PATCH 1/8] updated gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6143e53..079beb8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Compiled class file +.idea/* *.class - +*.iml # Log file *.log From cd5f5942e1a06360d10ce07fdbc950c0f5c9d1f7 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Sun, 24 Dec 2017 01:07:57 -0600 Subject: [PATCH 2/8] entered empty module.info --- inheritance/src/module-info.java | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 inheritance/src/module-info.java diff --git a/inheritance/src/module-info.java b/inheritance/src/module-info.java new file mode 100644 index 0000000..de8e3dd --- /dev/null +++ b/inheritance/src/module-info.java @@ -0,0 +1,3 @@ +module inheritance { + +} \ No newline at end of file From a0fbd97418c81f8d2e6a227b20aad828ab00283f Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Mon, 25 Dec 2017 13:34:15 -0600 Subject: [PATCH 3/8] cleaned up master --- inheritance/src/module-info.java | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 inheritance/src/module-info.java diff --git a/inheritance/src/module-info.java b/inheritance/src/module-info.java deleted file mode 100644 index de8e3dd..0000000 --- a/inheritance/src/module-info.java +++ /dev/null @@ -1,3 +0,0 @@ -module inheritance { - -} \ No newline at end of file From 9472a4bc7ec594c90ed33d64b32eb52750e56394 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Wed, 3 Jan 2018 00:48:15 -0600 Subject: [PATCH 4/8] added modules files --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 079beb8..719dd1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ # Compiled class file .idea/* *.class -*.iml + # Log file *.log - +*.iws # BlueJ files *.ctxt From 1abc5156ce28f907c7cfdeedb9e18c1a12181862 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Fri, 5 Jan 2018 07:00:17 -0600 Subject: [PATCH 5/8] Concept of complexity explained --- .classpath | 6 ++++ .project | 15 ++++++++++ DesignPatternsJava9.eml | 6 ++++ src/CyclomatricComplexity.java | 53 ++++++++++++++++++++++++++++++++++ src/CyclomatricSimplicity.java | 35 ++++++++++++++++++++++ 5 files changed, 115 insertions(+) create mode 100644 .classpath create mode 100644 .project create mode 100644 DesignPatternsJava9.eml create mode 100644 src/CyclomatricComplexity.java create mode 100644 src/CyclomatricSimplicity.java diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..f06d999 --- /dev/null +++ b/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/.project b/.project new file mode 100644 index 0000000..a33e785 --- /dev/null +++ b/.project @@ -0,0 +1,15 @@ + + + DesignPatternsJava9 + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.jdt.core.javanature + + diff --git a/DesignPatternsJava9.eml b/DesignPatternsJava9.eml new file mode 100644 index 0000000..82e1875 --- /dev/null +++ b/DesignPatternsJava9.eml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/CyclomatricComplexity.java b/src/CyclomatricComplexity.java new file mode 100644 index 0000000..861c192 --- /dev/null +++ b/src/CyclomatricComplexity.java @@ -0,0 +1,53 @@ +/* +@author: Aseem Jain +@title: Design Patterns with Java 9 +@link: https://premaseem.wordpress.com/category/computers/design-patterns/ +*/ +public class CyclomatricComplexity { + + /* + Problem Statement: Need to print biggest number from given numbers + */ + + public static void main (String[] args) { + + Integer a=7,b=4,c=10,d=18; + + if (a > b) { + if(a > c){ + if (a >d){ + System.out.println(a+ " is biggest"); + } + } + } + + if (b > c) { + if(b > d){ + if (b >a){ + System.out.println(b+ " is biggest"); + } + } + } + + if (c > b) { + if(c > a){ + if (c >d){ + System.out.println(c+" is biggest"); + } + } + } + + if (d > b) { + if(d > c){ + if (d >a){ + System.out.println(d+" is biggest"); + } + } + } + } +} + +// Take Away: +// If the decision points are more, then complexity of the program is more. +// If program has high complexity number, then probability of error is high +// with increased time for maintenance and trouble shoot. \ No newline at end of file diff --git a/src/CyclomatricSimplicity.java b/src/CyclomatricSimplicity.java new file mode 100644 index 0000000..f5b659c --- /dev/null +++ b/src/CyclomatricSimplicity.java @@ -0,0 +1,35 @@ +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/* +@author: Aseem Jain +@title: Design Patterns with Java 9 +@link: https://premaseem.wordpress.com/category/computers/design-patterns/ +*/ +public class CyclomatricSimplicity { + + /* + Problem Statement: Need to print biggest number from given numbers + */ + + public static void main (String[] args) { + + Integer a=7,b=4,c=10,d=18; + // Event when we need to modify parameter, things can be done + // with minimal code changes + + PrintBiggestNumber(a,b,c,d); + } + + private static void PrintBiggestNumber (Integer... numbers) { + System.out.println(); + List list = Arrays.asList(numbers); + Comparable max = Collections.max(list); + System.out.println(max + " is biggest (KISS)"); + } +} + +// Take Away: +// KISS - Keep it simple stupid. +// Design clean dry less code which can absorb changes. From 0a20831bd74e3c879f8c66bbb76d27d493448bb0 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Fri, 5 Jan 2018 07:01:44 -0600 Subject: [PATCH 6/8] Concept of complexity explained --- DesignPatternsJava9.iml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 DesignPatternsJava9.iml diff --git a/DesignPatternsJava9.iml b/DesignPatternsJava9.iml new file mode 100644 index 0000000..5a95221 --- /dev/null +++ b/DesignPatternsJava9.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file From 5741080bfc031088f852579770b4f04394ee3f26 Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Sat, 6 Jan 2018 22:23:08 -0600 Subject: [PATCH 7/8] Concept of complexity explained Update on Readme file --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 9e0034c..0e4d25e 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,14 @@ +## Video 2.1 of Design Patterns Tutorial uses this code + +# Cyclomatic complexity +Cyclomatic complexity is a source code complexity measurement that is being correlated to a number of coding errors. It is calculated by developing a Control Flow Graph of the code that measures the number of linearly-independent paths through a program module. +Lower the Program's cyclomatic complexity, lower the risk to modify and easier to understand. +Cyclomatic complexity = E - N + 2*P +where, + E = number of edges in the flow graph. + N = number of nodes in the flow graph. + P = number of nodes that have exit points + + # DesignPatternsJava9 This repo consists Gang of Four Design patterns code on Java 9. Each branch in the repository has code of 1 design pattern. Switch repository to try out different design patterns. From c30a5c92eb77cb7c15a1e14553db9d09909a819c Mon Sep 17 00:00:00 2001 From: Aseem Jain Date: Wed, 8 Aug 2018 19:01:12 -0500 Subject: [PATCH 8/8] Update README.md --- README.md | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 0e4d25e..d23c5ad 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,27 @@ -## Video 2.1 of Design Patterns Tutorial uses this code - -# Cyclomatic complexity +# What is Cyclomatic Complexity? Cyclomatic complexity is a source code complexity measurement that is being correlated to a number of coding errors. It is calculated by developing a Control Flow Graph of the code that measures the number of linearly-independent paths through a program module. + Lower the Program's cyclomatic complexity, lower the risk to modify and easier to understand. Cyclomatic complexity = E - N + 2*P where, - E = number of edges in the flow graph. - N = number of nodes in the flow graph. - P = number of nodes that have exit points +* E = number of edges in the flow graph. +* N = number of nodes in the flow graph. +* P = number of nodes that have exit points + + +If the decision points are more, then complexity of the program is more. If program has high complexity number, then probability of error is high with increased time for maintenance and trouble shoot. +#### Try to write linear code, which means wrap logic in reusable methods and use them. + +### Learn Design Patterns with Java by Aseem Jain +This repository contains working project code used in video Course by Packt Publication with title "Learn Design Patterns with Java " authored by "Aseem Jain". + +### Course link: +https://www.packtpub.com/application-development/learn-design-patterns-java-9-video + +### ![ http://in.linkedin.com/in/premaseem](https://github.com/premaseem/DesignPatternsJava9/blob/master/linkedin.png "http://in.linkedin.com/in/premaseem") Profile: http://in.linkedin.com/in/premaseem +### Authors blog on design patterns: +https://premaseem.wordpress.com/category/computers/design-patterns/ -# DesignPatternsJava9 -This repo consists Gang of Four Design patterns code on Java 9. Each branch in the repository has code of 1 design pattern. Switch repository to try out different design patterns. +### Software Design pattern community face book page: +https://www.facebook.com/DesignPatternGuru/