• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

a bunch of questions

 
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Studying for the test (Java 7) and looking at the objectives. Don't know these terms so just asking.

According to the regex API, \b is a word boundary and \B is a non-word boundary. But don't know what that means exactly or how to use them.

What's "virtual method invocation"?

In "Object-Oriented Design Principles", it says "Apply object composition principles." What does that mean?

What's the "Singleton design pattern"?

What's the "DAO pattern"?

"Design and create objects using a factory" Does that refer to a factory method, like DateFormat.getInstance() ?
 
Saloon Keeper
Posts: 15730
368
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevin Tysen wrote:According to the regex API, \b is a word boundary and \B is a non-word boundary. But don't know what that means exactly or how to use them.



It means they match to "zero width" parts of the input string, right before or after a word for \b, or otherwise for \B. For instance in the input string "hello world", \b would match at locations 0, 5, 6 and 11, and \B at everything else.

What's "virtual method invocation"?



I believe it refers to a method call in your code, without knowing exactly which method is going to get called until the moment at runtime where the invocation is actually performed. In Java, this is the case with overridden methods. For instance, when you call toString() on an object, you don't actually know if Object.toString() is going to get called, or maybe Subclass.toString(), or maybe even SubSubClass.toString().

In "Object-Oriented Design Principles", it says "Apply object composition principles." What does that mean?



Lots of beginners extend a class when they believe that their class should provide a lot of the same functions, or maybe they extend a class just because they think it's easy. The truth is that you should rarely have need to extend a class at all. Object composition means that instead of extending a class because you need its functions, you keep a member field referencing it instead.

What's the "Singleton design pattern"?



The Singleton pattern is a pattern where you make a class so it can only have one instance at any given time, and this instance is available globally. It should be used rarely, because global state (static fields) give lots of opportunities to introduce bugs in your program.

What's the "DAO pattern"?



I don't know exactly, I believe it stands for Data Access Object, and it refers to making objects out of entries usually found in databases, to manipulate them more easily. Do a Google search.

"Design and create objects using a factory" Does that refer to a factory method, like DateFormat.getInstance() ?



A factory is an object that exists for the creation of other objects. An example is the ThreadFactory class in java.util.concurrent. A factory method is a method that's responsible for returning instances of a particular type, usually the same type that contains the factory method. I rarely use factory methods, except for types that by nature have a limited amount of distinct instances (value objects). This enables you to force this limitation, and possibly even add caching. I've never designed a factory myself, only utility classes that contain a bunch of factory methods. An example: My Sudokus class that had createSudoku(), createXSudoku(), createSamuraiSudoku() methods, etc.

"Design and create objects using a factory" sounds like a very silly thing to preach as a hard and fast rule. It really depends on the situation.
 
Kevin Tysen
Ranch Hand
Posts: 255
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you! That really helps!
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since the OCP Java SE 7 exam objective mentions "Apply object composition principles", does it refer to multiple principles or just one - "favor composition over inheritance".

cheers
Andy
 
The only cure for that is hours of television radiation. And this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic