| @ -0,0 +1,26 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <classpath> | |||
| <classpathentry kind="src" output="target/classes" path="src/main/java"> | |||
| <attributes> | |||
| <attribute name="optional" value="true"/> | |||
| <attribute name="maven.pomderived" value="true"/> | |||
| </attributes> | |||
| </classpathentry> | |||
| <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | |||
| <attributes> | |||
| <attribute name="optional" value="true"/> | |||
| <attribute name="maven.pomderived" value="true"/> | |||
| </attributes> | |||
| </classpathentry> | |||
| <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> | |||
| <attributes> | |||
| <attribute name="maven.pomderived" value="true"/> | |||
| </attributes> | |||
| </classpathentry> | |||
| <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | |||
| <attributes> | |||
| <attribute name="maven.pomderived" value="true"/> | |||
| </attributes> | |||
| </classpathentry> | |||
| <classpathentry kind="output" path="target/classes"/> | |||
| </classpath> | |||
| @ -0,0 +1,23 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <projectDescription> | |||
| <name>s00.badcoupledsamplefixed</name> | |||
| <comment></comment> | |||
| <projects> | |||
| </projects> | |||
| <buildSpec> | |||
| <buildCommand> | |||
| <name>org.eclipse.jdt.core.javabuilder</name> | |||
| <arguments> | |||
| </arguments> | |||
| </buildCommand> | |||
| <buildCommand> | |||
| <name>org.eclipse.m2e.core.maven2Builder</name> | |||
| <arguments> | |||
| </arguments> | |||
| </buildCommand> | |||
| </buildSpec> | |||
| <natures> | |||
| <nature>org.eclipse.jdt.core.javanature</nature> | |||
| <nature>org.eclipse.m2e.core.maven2Nature</nature> | |||
| </natures> | |||
| </projectDescription> | |||
| @ -0,0 +1,4 @@ | |||
| eclipse.preferences.version=1 | |||
| encoding//src/main/java=UTF-8 | |||
| encoding//src/test/java=UTF-8 | |||
| encoding/<project>=UTF-8 | |||
| @ -0,0 +1,5 @@ | |||
| eclipse.preferences.version=1 | |||
| org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 | |||
| org.eclipse.jdt.core.compiler.compliance=1.5 | |||
| org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning | |||
| org.eclipse.jdt.core.compiler.source=1.5 | |||
| @ -0,0 +1,4 @@ | |||
| activeProfiles= | |||
| eclipse.preferences.version=1 | |||
| resolveWorkspaceProjects=true | |||
| version=1 | |||
| @ -0,0 +1,25 @@ | |||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |||
| <modelVersion>4.0.0</modelVersion> | |||
| <groupId>es.anaya.spring.badcode</groupId> | |||
| <artifactId>s00.badcoupledsamplefixed</artifactId> | |||
| <version>0.0.1-SNAPSHOT</version> | |||
| <packaging>jar</packaging> | |||
| <name>s00.badcoupledsamplefixed</name> | |||
| <url>http://maven.apache.org</url> | |||
| <properties> | |||
| <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | |||
| </properties> | |||
| <dependencies> | |||
| <dependency> | |||
| <groupId>junit</groupId> | |||
| <artifactId>junit</artifactId> | |||
| <version>3.8.1</version> | |||
| <scope>test</scope> | |||
| </dependency> | |||
| </dependencies> | |||
| </project> | |||
| @ -0,0 +1,79 @@ | |||
| <?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> | |||
| @ -0,0 +1,10 @@ | |||
| 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,0 +1,24 @@ | |||
| package es.anaya.spring.badcode.s00.badcoupledsamplefixed; | |||
| import java.util.ArrayList; | |||
| public class CsvFileDataSource { | |||
| 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,0 +1,21 @@ | |||
| package es.anaya.spring.badcode.s00.badcoupledsamplefixed; | |||
| import java.util.ArrayList; | |||
| public class CustomerList { | |||
| private CsvFileDataSource csvFileDataSource; | |||
| private ArrayList<String> customerData; | |||
| public CustomerList (CsvFileDataSource csvFileDataSource) { | |||
| this.customerData = new ArrayList<String>(); | |||
| this.csvFileDataSource = csvFileDataSource; | |||
| } | |||
| public void loadFile (String filename, String separator) { | |||
| customerData = csvFileDataSource.loadData(); | |||
| } | |||
| public String showAll () { | |||
| return customerData.toString(); | |||
| } | |||
| } | |||
| @ -0,0 +1,10 @@ | |||
| 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,0 +1,24 @@ | |||
| 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,0 +1,21 @@ | |||
| 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,0 +1,7 @@ | |||
| package es.anaya.spring.badcode.s00.badcoupledsamplefixedwithinterfaces; | |||
| import java.util.ArrayList; | |||
| public interface DataSource { | |||
| public ArrayList<String> loadData(); | |||
| } | |||
| @ -0,0 +1,38 @@ | |||
| package es.anaya.spring.badcode.s00.badcoupledsample; | |||
| import junit.framework.Test; | |||
| import junit.framework.TestCase; | |||
| import junit.framework.TestSuite; | |||
| /** | |||
| * Unit test for simple App. | |||
| */ | |||
| public class AppTest | |||
| extends TestCase | |||
| { | |||
| /** | |||
| * Create the test case | |||
| * | |||
| * @param testName name of the test case | |||
| */ | |||
| public AppTest( String testName ) | |||
| { | |||
| super( testName ); | |||
| } | |||
| /** | |||
| * @return the suite of tests being tested | |||
| */ | |||
| public static Test suite() | |||
| { | |||
| return new TestSuite( AppTest.class ); | |||
| } | |||
| /** | |||
| * Rigourous Test :-) | |||
| */ | |||
| public void testApp() | |||
| { | |||
| assertTrue( true ); | |||
| } | |||
| } | |||