Your SlideShare is downloading. ×
0
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
All the Java ADF beginners need to know - part2
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

All the Java ADF beginners need to know - part2

3,613

Published on

This is a mini-lesson on Java concepts and syntax, aimed at PL/SQL developers and DBAs who need to know sufficient Java to start build ADF Components with Java. …

This is a mini-lesson on Java concepts and syntax, aimed at PL/SQL developers and DBAs who need to know sufficient Java to start build ADF Components with Java.
Held at KScope 11 in Long Beach.

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,613
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
134
Comments
0
Likes
1
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. All the Java ADF Beginners need to know! – Part 2 Markus Eisele Oracle ACE Director msg systems ag, Germany1 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 2. http://blog.eisele.nethttp://twitter.com/myfearmarkus@eisele.net
  • 3. Overview 1. Introduction 2. Basic Object Oriented Concepts 3. Classes and Objects 4. Exceptions 5. Generics 6. Design Pattern3 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 4. Introduction • YOU„VE MISSED (or skipped) part 1 ;) (The real basics) • Let„s get more theoretical and detailed now! • Disclaimer: Even if there is “ADF” in the title, we still don’t touch ADF or even open up JDeveloper …4 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 5. Why do you have „ADF“ in the title?5 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 6. What is Object Orientation? Procedural paradigm: • Software is organized around the notion of procedures • Procedural abstraction  Works as long as the data is simple • Adding data abstractions  Groups together the pieces of data that describe some entity  Helps reduce the system‟s complexity. - Such as Records and structures Object oriented paradigm: • Organizing procedural abstractions in the context of data abstractions6 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 7. Object Orientation paradigm An approach to the solution of problems in which all computations are performed in the context of objects. • The objects are instances of classes, which:  are data abstractions  contain procedural abstractions that operation on the objects • A running program can be seen as a collection of objects collaborating to perform a given task7 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 8. Concepts that Define Object Orientation Necessary for a system or language to be object oriented (OO) • Identity  Each object is distinct from each other object, and can be referred to  Two objects are distinct even if they have the same data • Classes  The code is organized using classes, each of which describes a set of objects • Inheritance  The mechanism where features in a hierarchy inherit from superclasses to subclasses • Polymorphism  The mechanism by which several methods can have the same name and implement the same abstract operation.8 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, JUNE 26 - 2011
  • 9. Other Concepts • Abstraction  Object -> something in the world  Class -> objects  Superclass -> subclasses  Operation -> methods  Attributes and associations -> instance variables • Modularity  Code can be constructed entirely of classes • Encapsulation  Details can be hidden in classes  This gives rise to information hiding:  Programmers do not need to know all the details of a class9 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, JUNE 26 - 2011
  • 10. Classes and Objects • Object  A chunk of structured data  Has properties (attributes)  Representing it„s state  Has behaviour (methods)  Representing how it acts and reacts  Simulates the behaviour of the object in the real worl • Class  Is a unit of abstraction  It„s instances represent similar objects  Is a kind of software module  Has methods  to implement behaviour10 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 11. Class or Instance? • Something should be a class if it could have instances • Something should be an instance if it is clearly a single member of a set defined by a class • Person  Class: instances are individual persons • Markus  Instance: A person with the name: „Markus“ • … • The act of creating an object instance of a class is called the instantiation of the class.  Person markus = new Person(„Markus“);11 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 12. Name your Classes • Use capital letters  Classes always start with capital letters  E.g. CellPhone NOT cellPhone • Use singular nouns  A class is a generalization of a single object.  E.g. Person NOT Persons • Use the right level of generality  This highly depends on souroundings. Be as specific as needed.  E.g. Cat not Animal • Make sure the name has only one meaning12 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 13. Encapsulation and Class attributes and methods • Attributes and methods have visibility modifier  private Visible to all class internal methods and attributes. private List<Person> attendees;  protected Visible to all the classes within the same package and to sub-classes. protected List<Person> getAttendees();  public Visible outside the class. Public interface to access and manipulate objects public Date fromDate;  No modifier / package-private Visible outside the class. Public interface to access and manipulate objects • Class attributes and methods are marked with the keyword „static“. Can be combined with any of the above visibility modifier.  protected static int MAX_ATTENDEES;13 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 14. Inheritance • Classes can be organized into a hierarchical inheritance structure, where a child class inherits attributes from a parent class. Also known synonymously as an inheritance tree. • A child class is synonymous with the term subclass or derived class. The parent class is synonymous with the terms superclass or base class. • The inheritance tree may run many levels deep. • In a pure Object-Oriented system, a class may support multiple inheritance. public class Student extends Person { } • Always check generalizations to ensure they obey the “is a” rule:  “A Student is a Person”  “A village is a municipality”14 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 15. Abstract classes and methods • An operation should be declared to exist at the highest class in the hierarchy where it makes sense  The operation may be abstract (lacking implementation) at that level  If so, the class also must be abstract  No instances can be created  The opposite of an abstract class is a concrete class • If a superclass has an abstract operation then its subclasses at some level must have a concrete method for the operation  Leaf classes must have or inherit concrete methods for all operations  Leaf classes must be concrete public abstract class Person { public abstract String drinkingHabits(); } public class Student extends Person { public String drinkingHabits() { return "Lot of beer!"; } }15 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 16. Polymorphism • One object calls another through a message, specifying a called method. If that method is found within the receiver class, the method is invoked. If the method is not found the receiver class‟s parent class equivalent method is invoked, and so on. This behavior is called polymorphism • Polymorphism extends not only to the methods but also the attributes of an object. public class Person { private String name; private String surename; public Person(String name, String surename) { this.name = name; this.surename = surename; } } public class Student extends Person { public Student(String name, String surename) { super(name,surename); } }16 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 17. Interfaces • Like abstract classes, but cannot have executable statements  Define a set of operations that make sense in several classes  Abstract Data Types • A class can implement any number of interfaces  It must have concrete methods for the operations public interface Mammal { public abstract List<Mammal> getChildren(); } public abstract class Person implements Mammal { public List<Mammal> getChildren() { return Collections.emptyList(); } }17 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 18. Exceptions • Anything that can go wrong should result in the raising of an Exception. Exception is a class with many subclasses for specific things that can go wrong. • Use a try - catch block to trap an exception try { int x = 1/0; } catch (ArithmeticException e) { // code to handle division by zero }18 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 19. Generics • J2SE 5.0 and higher provides compile-time type safety with the Java Collections framework through generics • Generics allows you to specify, at compile-time, the types of objects you want to store in a Collection. Then when you add and get items from the list, the list already knows what types of objects are supposed to be acted on. • So you dont need to cast anything. The "<>" characters are used to designate what type is to be stored. If the wrong type of data is provided, a compile-time exception is thrown. Sample<String> object = new Sample<String>(); public class Sample<T> { private T data; public void setData(T newData) { data = newData; } public T getData() { return data; } }19 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 20. Design Pattern • The recurring aspects of designs are called design patterns.  A pattern is the outline of a reusable solution to a general problem encountered in a particular context  Many of them have been systematically documented for all software developers to use  A good pattern should  Be as general as possible  Contain a solution that has been proven to effectively solve the problem in the indicated context. Studying patterns is an effective way to learn from the experience of others20 Markus Eisele msg systems ag, JUNE 26 - 2011
  • 21. Description of Pattern Context: • The general situation in which the pattern applies Problem:  A short sentence or two raising the main difficulty. Forces: • The issues or concerns to consider when solving the problem Solution: • The recommended way to solve the problem in the given context. —„to balance the forces‟ Antipatterns: (Optional) • Solutions that are inferior or do not work in this context. Related patterns: (Optional) • Patterns that are similar to this pattern. References: • Who developed or inspired the pattern.21 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, JUNE 26 - 2011
  • 22. Example Singleton Design pattern • Singletons can be used to create for example Connection Pool. If programmers create a new connection object in every class that requires it, then its clear waste of resources. In this scenario by using a singleton connection class we can maintain a single connection object which can be used throughout the application.22 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, JUNE 26 - 2011
  • 23. Gang of Four (GoF) Pattern Design Patterns, Elements of Reusable Object-Oriented Software - Erich Gamma, Richard Helm, Ralph Johnson, John M. ISBN: 978-0-2016-3361-0 http://bit.ly/iojEpw23 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, JUNE 26 - 2011
  • 24. Lesson in a tweet “Good programmers use their brains, but good guidelines save us having to think out every case.” (Francis Glassborow) http://www.devtopics.com/101-great-computer-programming-quotes/24 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, 26/06/11
  • 25. Thanks! http://www.sagecomputing.com.au/25 Markus Eisele, Oracle ACE Director FMW & SOA msg systems ag, 26/06/11
  • 26. Thank you for your attention Markus Eisele Principle IT Architect http://blog.eisele.net http://twitter.com/myfear www.msg-systems.com www.msg-systems.com26 Markus Eisele msg systems ag, JUNE 26 - 2011

×