Compare commits

...

No commits in common. 'S00.badcouplesamplefixed' and 's00.badcoupled' have entirely different histories.

20 changed files with 150 additions and 158 deletions
Unified View
  1. +8
    -0
      .idea/.gitignore
  2. +6
    -0
      .idea/misc.xml
  3. +6
    -0
      .idea/vcs.xml
  4. +1
    -1
      .project
  5. BIN
      Untitled.gif
  6. +2
    -2
      pom.xml
  7. BIN
      s00.badcoupledsample.jpg.jpg
  8. +55
    -0
      s00.badcoupledsample.jpg.ucls
  9. BIN
      s00.badcoupledsample.png
  10. +59
    -0
      s00.badcoupledsample.ucls
  11. BIN
      s00.badcoupledsamplefixed.UCLS.png
  12. +0
    -79
      s00.badcoupledsamplefixed.UCLS.ucls
  13. +9
    -0
      src/main/java/es/anaya/spring/badcode/s00/badcoupled/App.java
  14. +1
    -1
      src/main/java/es/anaya/spring/badcode/s00/badcoupled/CsvFileDataSource.java
  15. +3
    -3
      src/main/java/es/anaya/spring/badcode/s00/badcoupled/CustomerList.java
  16. +0
    -10
      src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixed/App.java
  17. +0
    -10
      src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/App.java
  18. +0
    -24
      src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CsvFileDataSource.java
  19. +0
    -21
      src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CustomerList.java
  20. +0
    -7
      src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/DataSource.java

+ 8
- 0
.idea/.gitignore View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

+ 6
- 0
.idea/misc.xml View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/classes" />
</component>
</project>

+ 6
- 0
.idea/vcs.xml View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>

+ 1
- 1
.project View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>s00.badcoupledsamplefixed</name>
<name>s00.badcoupledsample</name>
<comment></comment> <comment></comment>
<projects> <projects>
</projects> </projects>


BIN
Untitled.gif View File

Before After
Width: 643  |  Height: 93  |  Size: 3.5 KiB

+ 2
- 2
pom.xml View File

@ -3,11 +3,11 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>es.anaya.spring.badcode</groupId> <groupId>es.anaya.spring.badcode</groupId>
<artifactId>s00.badcoupledsamplefixed</artifactId>
<artifactId>s00.badcoupled</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>s00.badcoupledsamplefixed</name>
<name>s00.badcoupled</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>


BIN
s00.badcoupledsample.jpg.jpg View File

Before After
Width: 643  |  Height: 93  |  Size: 16 KiB

+ 55
- 0
s00.badcoupledsample.jpg.ucls View File

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.2" icons="false" automaticImage="JPEG" always-add-relationships="true"
generalizations="true" realizations="true" associations="true" dependencies="true" nesting-relationships="true"
router="FAN">
<class id="1" language="java" name="es.anaya.spring.badcode.s00.badcoupled.App" project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/App.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="208" y="296"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="2" language="java" name="es.anaya.spring.badcode.s00.badcoupled.CsvFileDataSource"
project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/CsvFileDataSource.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="704" y="296"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="es.anaya.spring.badcode.s00.badcoupled.CustomerList"
project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/CustomerList.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="396" y="296"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<association id="4">
<end type="SOURCE" refId="3" navigable="false">
<attribute id="5" name="csvFileDataSource"/>
<multiplicity id="6" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<dependency id="7">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/>
</dependency>
<classifier-display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

BIN
s00.badcoupledsample.png View File

Before After
Width: 625  |  Height: 93  |  Size: 8.9 KiB

+ 59
- 0
s00.badcoupledsample.ucls View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.2" icons="false" automaticImage="PNG" always-add-relationships="false"
generalizations="true" realizations="true" associations="true" dependencies="true" nesting-relationships="true"
router="FAN">
<class id="1" language="java" name="es.anaya.spring.badcode.s00.badcoupled.App" project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/App.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="119" y="165"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="2" language="java" name="es.anaya.spring.badcode.s00.badcoupled.CsvFileDataSource"
project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/CsvFileDataSource.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="597" y="165"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="3" language="java" name="es.anaya.spring.badcode.s00.badcoupled.CustomerList"
project="s00.badcoupledsample"
file="/s00.badcoupledsample/src/main/java/es/anaya/spring/badcode/s00/badcoupled/CustomerList.java" binary="false"
corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="301" y="165"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<dependency id="4">
<end type="SOURCE" refId="1"/>
<end type="TARGET" refId="3"/>
</dependency>
<association id="5">
<end type="SOURCE" refId="3" navigable="false">
<attribute id="6" name="csvFileDataSource">
<position height="0" width="0" x="-21" y="4"/>
</attribute>
<multiplicity id="7" minimum="0" maximum="1">
<position height="0" width="0" x="-21" y="4"/>
</multiplicity>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<classifier-display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

BIN
s00.badcoupledsamplefixed.UCLS.png View File

Before After
Width: 569  |  Height: 179  |  Size: 14 KiB

+ 0
- 79
s00.badcoupledsamplefixed.UCLS.ucls View File

@ -1,79 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<class-diagram version="1.2.2" icons="false" automaticImage="PNG" always-add-relationships="false"
generalizations="true" realizations="true" associations="true" dependencies="true" nesting-relationships="true"
router="FAN">
<class id="1" language="java" name="es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces.CustomerList"
project="s00.badcoupledsamplefixed"
file="/s00.badcoupledsamplefixed/src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CustomerList.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="150" y="131"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<interface id="2" language="java" name="es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces.DataSource"
project="s00.badcoupledsamplefixed"
file="/s00.badcoupledsamplefixed/src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/DataSource.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="345" y="238"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</interface>
<class id="3" language="java" name="es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces.CsvFileDataSource"
project="s00.badcoupledsamplefixed"
file="/s00.badcoupledsamplefixed/src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CsvFileDataSource.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="538" y="131"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<class id="4" language="java" name="es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces.App"
project="s00.badcoupledsamplefixed"
file="/s00.badcoupledsamplefixed/src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/App.java"
binary="false" corner="BOTTOM_RIGHT">
<position height="-1" width="-1" x="345" y="131"/>
<display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</display>
</class>
<dependency id="5">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="3"/>
</dependency>
<dependency id="6">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="1"/>
</dependency>
<association id="7">
<end type="SOURCE" refId="1" navigable="false">
<attribute id="8" name="dataSource"/>
<multiplicity id="9" minimum="0" maximum="1"/>
</end>
<end type="TARGET" refId="2" navigable="true"/>
<display labels="true" multiplicity="true"/>
</association>
<realization id="10">
<end type="SOURCE" refId="3"/>
<end type="TARGET" refId="2"/>
</realization>
<dependency id="11">
<end type="SOURCE" refId="4"/>
<end type="TARGET" refId="2"/>
</dependency>
<classifier-display autosize="true" stereotype="false" package="false" initial-value="false" signature="true"
sort-features="false" accessors="false" visibility="true">
<attributes public="true" package="true" protected="true" private="true" static="true"/>
<operations public="true" package="true" protected="true" private="true" static="true"/>
</classifier-display>
<association-display labels="true" multiplicity="true"/>
</class-diagram>

+ 9
- 0
src/main/java/es/anaya/spring/badcode/s00/badcoupled/App.java View File

@ -0,0 +1,9 @@
package es.anaya.spring.badcode.s00.badcoupled;
public class App {
public static void main(String[] args) {
CustomerList customerList = new CustomerList();
customerList.loadFile("samplefile.csv", ";");
System.out.println(customerList.showAll());
}
}

src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixed/CsvFileDataSource.java → src/main/java/es/anaya/spring/badcode/s00/badcoupled/CsvFileDataSource.java View File

@ -1,4 +1,4 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixed;
package es.anaya.spring.badcode.s00.badcoupled;
import java.util.ArrayList; import java.util.ArrayList;

src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixed/CustomerList.java → src/main/java/es/anaya/spring/badcode/s00/badcoupled/CustomerList.java View File

@ -1,4 +1,4 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixed;
package es.anaya.spring.badcode.s00.badcoupled;
import java.util.ArrayList; import java.util.ArrayList;
@ -6,12 +6,12 @@ public class CustomerList {
private CsvFileDataSource csvFileDataSource; private CsvFileDataSource csvFileDataSource;
private ArrayList<String> customerData; private ArrayList<String> customerData;
public CustomerList (CsvFileDataSource csvFileDataSource) {
public CustomerList () {
this.customerData = new ArrayList<String>(); this.customerData = new ArrayList<String>();
this.csvFileDataSource = csvFileDataSource;
} }
public void loadFile (String filename, String separator) { public void loadFile (String filename, String separator) {
csvFileDataSource = new CsvFileDataSource(filename, separator);
customerData = csvFileDataSource.loadData(); customerData = csvFileDataSource.loadData();
} }

+ 0
- 10
src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixed/App.java View File

@ -1,10 +0,0 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixed;
public class App {
public static void main(String[] args) {
CsvFileDataSource csvFileDataSource = new CsvFileDataSource("file.csv", ";");
CustomerList customerList = new CustomerList(csvFileDataSource);
customerList.loadFile("samplefile.csv", ";");
System.out.println(customerList.showAll());
}
}

+ 0
- 10
src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/App.java View File

@ -1,10 +0,0 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces;
public class App {
public static void main(String[] args) {
DataSource csvFileDataSource = new CsvFileDataSource("file.csv", ";");
CustomerList customerList = new CustomerList(csvFileDataSource);
customerList.loadFile("samplefile.csv", ";");
System.out.println(customerList.showAll());
}
}

+ 0
- 24
src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CsvFileDataSource.java View File

@ -1,24 +0,0 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces;
import java.util.ArrayList;
public class CsvFileDataSource implements DataSource {
private String filename;
private String separator;
public CsvFileDataSource(String filename, String separator) {
this.filename = filename;
this.separator = separator;
}
public ArrayList<String> loadData() {
ArrayList<String> lines = new ArrayList<String>();
lines.add("Customer1, [email protected], 234 street");
lines.add("Customer2, [email protected], 523 street");
lines.add("Customer3, [email protected], 231 street");
return lines;
}
}

+ 0
- 21
src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/CustomerList.java View File

@ -1,21 +0,0 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces;
import java.util.ArrayList;
public class CustomerList {
private DataSource dataSource;
private ArrayList<String> customerData;
public CustomerList (DataSource dataSource) {
this.customerData = new ArrayList<String>();
this.dataSource = dataSource;
}
public void loadFile (String filename, String separator) {
customerData = dataSource.loadData();
}
public String showAll () {
return customerData.toString();
}
}

+ 0
- 7
src/main/java/es/anaya/spring/badcode/s00/badcoupledsamplefixedwithinterfaces/DataSource.java View File

@ -1,7 +0,0 @@
package es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces;
import java.util.ArrayList;
public interface DataSource {
public ArrayList<String> loadData();
}

Loading…
Cancel
Save