Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 28 additions & 28 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
16 changes: 8 additions & 8 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

246 changes: 123 additions & 123 deletions .idea/uiDesigner.xml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions AdvancedProgramming.iml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/annotations-24.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/annotations-24.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Advanced-Programming
A Repository for Programming Exercises and Assignments in Advanced Programming
# Advanced-Programming
A Repository for Programming Exercises and Assignments in Advanced Programming
36 changes: 18 additions & 18 deletions src/Lecture1_adt/Transaction1.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package Lecture1_adt;

import java.util.Calendar;

/**
* This Lecture1_adt.TransactionInterface Class violates several ADT design principles:
* 1. Representation Independence: --- Changes in representation of the data may require external code to alter access
* 2. Preservation of Invariants: --- Any external client code can alter the internal values
*/
public class Transaction1 {
public int amount;
public Calendar date;

public Transaction1(int amount, Calendar date) {
this.amount = amount;
this.date = (Calendar) date.clone();
}
}
package Lecture1_adt;
import java.util.Calendar;
/**
* This Lecture1_adt.TransactionInterface Class violates several ADT design principles:
* 1. Representation Independence: --- Changes in representation of the data may require external code to alter access
* 2. Preservation of Invariants: --- Any external client code can alter the internal values
*/
public class Transaction1 {
public int amount;
public Calendar date;
public Transaction1(int amount, Calendar date) {
this.amount = amount;
this.date = (Calendar) date.clone();
}
}
72 changes: 36 additions & 36 deletions src/Lecture1_adt/Transaction2.java
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package Lecture1_adt;

import org.jetbrains.annotations.NotNull;

import java.util.Calendar;
//import java.util.Date;

/**
* This Lecture1_adt.Transaction2 Class Takes the first step to resolves the ADT design issues of Transaction1:
* 1. Representation Independence: --- Encapsulation - Providing access methods to the internal data.
* External client code only access via allowable operations
* --- Changes to internal representation can still be accessed via same methods defined
*
* 2. Preservation of Invariants: --- Access Modifies private final makes the data Unchangeable
*
* Lecture1_adt
*/

public class Transaction2 {
private final int amount;
private final Calendar date;

public Transaction2(int amount, @NotNull Calendar date) {
this.amount = amount;
this.date = date;
}

public int getAmount() {
return amount; // Because we are dealing with Value types we need not worry about what we return
}

public Calendar getDate() {
// return date; // Because we are dealing with Reference types we need to judiciously copy what our getters return
return (Calendar) date.clone(); // Defensive copying or Judicious Copying
}
}
package Lecture1_adt;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
//import java.util.Date;
/**
* This Lecture1_adt.Transaction2 Class Takes the first step to resolves the ADT design issues of Transaction1:
* 1. Representation Independence: --- Encapsulation - Providing access methods to the internal data.
* External client code only access via allowable operations
* --- Changes to internal representation can still be accessed via same methods defined
*
* 2. Preservation of Invariants: --- Access Modifies private final makes the data Unchangeable
*
* Lecture1_adt
*/
public class Transaction2 {
private final int amount;
private final Calendar date;
public Transaction2(int amount, @NotNull Calendar date) {
this.amount = amount;
this.date = date;
}
public int getAmount() {
return amount; // Because we are dealing with Value types we need not worry about what we return
}
public Calendar getDate() {
// return date; // Because we are dealing with Reference types we need to judiciously copy what our getters return
return (Calendar) date.clone(); // Defensive copying or Judicious Copying
}
}
62 changes: 31 additions & 31 deletions src/Lecture1_adt/Transaction3.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
package Lecture1_adt;

import org.jetbrains.annotations.NotNull;

import java.util.Calendar;

/**
* There is still Exposure seen in Transaction2 I that if we make next payment the date of first payment is also altered
* This Class Transaction3:Adds Code to correct this exposure:
* Intentional review of any methods that receive produces (returns)
* If produces interface of a method deals with objects or any reference types,
* there is need to perform defensive copying to enhance Invariant preservation
*/
public class Transaction3 {
private final int amount;
private final Calendar date;

public Transaction3(int amount, @NotNull Calendar date) {
this.amount = amount;
this.date = date;
}

public int getAmount() {
return amount; // Because we are dealing with Value types we need not worry about what we return
}

public Calendar getDate() {
// return date; // Because we are dealing with Reference types we need to judiciously copy what our getters return
return (Calendar) date.clone(); // Defensive copying or Judicious Copying
}
}
package Lecture1_adt;
import org.jetbrains.annotations.NotNull;
import java.util.Calendar;
/**
* There is still Exposure seen in Transaction2 I that if we make next payment the date of first payment is also altered
* This Class Transaction3:Adds Code to correct this exposure:
* Intentional review of any methods that receive produces (returns)
* If produces interface of a method deals with objects or any reference types,
* there is need to perform defensive copying to enhance Invariant preservation
*/
public class Transaction3 {
private final int amount;
private final Calendar date;
public Transaction3(int amount, @NotNull Calendar date) {
this.amount = amount;
this.date = date;
}
public int getAmount() {
return amount; // Because we are dealing with Value types we need not worry about what we return
}
public Calendar getDate() {
// return date; // Because we are dealing with Reference types we need to judiciously copy what our getters return
return (Calendar) date.clone(); // Defensive copying or Judicious Copying
}
}
Loading