Object-Oriented in Java User (screen) Task I - code to interact w/ User Task II - business rules and logic Task III - access external software (like DBs) Data When using an OO language we seperate these tasks into different classes, and we reuse code In Java each class does 1 job (and does it well) and we reuse existing classes as needed Task I - becomes the program entry point (the main method code) and contains the program flow Task II - becomes the holder of the data sets we call these Entity classes an Entity class is like a DSECT or Cobol Copybook it has a set of data fields, AND the business rules to use these fields Task III - becomes the worker class to read/write files Databse records, etc DBs use SQL, and I want to put the SQL in only 1 place so if the external DB changes, I go ONLY 1 place in the Java code to fix it these classes are called Action classes, and have methods to do work ------------------------------------------------------------ When building an OO Appl, I create: 1 Appl class w/ the main method that controls teh program flow an Entity class for each set of data (inpout/output/etc) needed in the Appl an Action class for each external data source/target (DB table of XML file or ???) ======================================= in the CurrencyExample I have: CurrencyAppl -> Task I Currency -> Entity (Task II) CurrencyReader CurrencyWriter -> Actions (Task III) ---------------------------------------------------------------- I have a "bunch" of classes, each class does 1 job I have a number of OO terms that apply Class -> this is the Java code I write I write a class once and use it a lot for example I have Currency.java (an Entity class) and my input file has 438 line of data, so I end up with 438 instances of this class each instance has it's own copy of the fields Object -> this is a specific instance of the class, and Object has memory and data in the class fields so the Currency Object for Brazil is in memory next to the Currency Object for Canada an Object is a field in my code, and each field is of a specific Data Type Package -> a folder in the src tree to organize my Java code since Java 9 modules, packages are "required?" a package gives a fully qualified name to the Java class a package should be unique, so we put our Intnet domain name as part of the package name gov.irs....class private -> when used on a field within an Entity class, ONLY the code (methods) of this Entity class have access to the field this means I can implement the business rules in teh Entity class and that will be the ONLY place the rules are coded public -> when used on a method of an Entity class (or an Action class) this method maybe called by another class (like the main) and here is where we code the business rules protected -> this class and the child classes of this class can access protected fields or methods - this is "package" access, and classes in the same package (folder) can access the fields/methods this is the default is you do not code an access type and this is discouraged constructor -> a method with the same name as the class, and is used to intialize the fields, it sis ONLY called via the "new" command override - is when the child class redefines the method from the parent class and has a different implementation of the method final - is consent, a final field cannot change a final method cannot be overridden a final class cannot be extended abstract - MUST be overridden or extended a abstract method MUST be overridden by the child class or the child class will not compile a abstract class must be extended, and you cannot construct an instance of an abstract class ------------------------------------------------------------- In Object-Oriented Programming I write a class, then I build an Object of that class.... public class PopulationRecord { .... } then in my main I code: PopulationRecord current = new PopulationRecord(); ^ the Data Type ^ the the Object ^ building in memory my Object Or I can build an Object out of a pre-existing class String name = "Jonathan"; ^datatype is String ^ the ojbect (field) is called name ^ I build it out of literal (built by the compiler)