IS-A is tied to inheritance of one class by another class and HAS-A is tied to member instance variable of another class.
1) Both IS-A and HAS-A offer code reuse
Both result in the re-use of code already written in another class.
2) Run time polymorphism can be achieved with IS-A and not with HAS-A
Since IS-A is tied to inheritance so run-time polymorphism is achievable through IS-A relationship.
3) IS-A results in increased coupling between two classes but HAS-A usually draws a line on coupling
IS-A should be used when cohesion is to be increased but HAS-A has no visible effect on cohesion
4) The container class manages the lifecycle of contained class’s object in HAS-A relationship but the super class doesn’t play any role in the lifecycle of sub class’s object in IS-A relationship.
5) HAS-A relationship is closely related to another term named as Delegation.
When the container class invokes some method on the contained class’s object then the container is said to have delegated the call to container object.
6) IS-A can be visualized as a parent-child or vertical relationship.
HAS-A can be visualized as sibling or horizontal relationship.
Use IS-A relationship for closely related classes with sub class being more specific version of super class and use HAS-A relationship for possession kind of relationships
Tags
Feb 22, 2012
Feb 21, 2012
Graphic presentations of FindBugs results using Maven
To enable FindBugs reporting in Maven, just add report section to your pom files
Finally use mvn dashboard:dashboard to generate charts.
Voila. We have got nice graphic reports.
Well, not so nice. We have bugs we need to fix.
Then you can just use command mvn site if you want to generate more comprehensive project information or mvn findbugs:findbugs for only FindBugs reports.org.codehaus.mojo findbugs-maven-plugin 2.3 exclude.xml true true Low Max true
Finally use mvn dashboard:dashboard to generate charts.
Voila. We have got nice graphic reports.
Well, not so nice. We have bugs we need to fix.
Labels:
maven
Feb 20, 2012
Frequently Asked Question about strings
Q: Why is String class immutable?
Ans: As string objects are used the most hence to avoid placing synchronization blocks at every place where multiple threads should not access string object simultaneously, String class was made immutable
Q: What is the difference between String, StringBuffer and StringBuilder?
Ans: String is immutable. StringBuffer provides immutability but has synchronized methods and StringBuilder class has similar features as StringBuffer but has non-synchronized methods
Q:What is the difference between a String object created on String pool and on the heap? Or What will be the result of following statements?
1) “abc” == “abc”
2) new String(“abc”) == new String(“abc”)
1) “abc” == “abc”
2) new String(“abc”) == new String(“abc”)
Ans: The second object created with same content using String literal means both are pointing to same object in pool. But if created using new operator then each one takes new memory space even if they have same characters
Q: Which new feature has been added to JDK 7 regarding Strings?
Ans: Strings can now be used in Switch/Case statements
Q: What happens when concatenation operator is used with Strings as shown in 1 and 2 below:
1) String str1 = “abc”;
String str2 = “def”;
String str3 = str1 + str2;
2) String str4 = “abc” + “def”;
1) String str1 = “abc”;
String str2 = “def”;
String str3 = str1 + str2;
2) String str4 = “abc” + “def”;
Ans: 1) doesn’t result in such optimization and hence creates more number of String objects
2)results in compiler optimization and hence the statement becomes String str4 = “abcdef”; after compilation
Labels:
Interview tips,
java
Feb 1, 2012
Know your strengths and weaknesses-Software careers
I have listed down "checklist" here that covers various areas of knowledge in the IT industry.
software development consists of these skill areas:
- Programming
- Database management
- Analysis ,Design
- Testing
- Communication
- Development processes
Programming
Some things you should understand about programming:
- Understanding one or more languages
- Understanding language libraries/frameworks (Spring,Hibernate, JSF, Struts)
- Understanding tools (Ant, maven, hudson)
- Understanding IDE's (Eclipse, NetBeans)
- HTML, CSS, JavaScript, DHTML, AJAX
Database management
Knowledge areas in database management:
- Database design
- Awareness of Oracle, MySQL, Postgressql
Business analysis
Things you should understand as a business analyst:
- Use cases
- UML
- Database design
- Data flows
- Cost estimating
- Function Point Analysis (FPA)
- Cocomo, or something like it
- Roles in the analysis process
- How to write use cases and requirements specifications
Testing
Knowledge areas in the field of software quality:
- Testing (unit, regression, code coverage, GUI testing)
Communication
Your strengths and weaknesses as a communicator:
- Technical writing
- Verbal communication
- Ability to lead a team
- Communication as a manager
- Communication as an employee
Software development processes
Your knowledge of software development practices:
- Scrum
- "agile"
Labels:
Best Practices
Software development best practices
- Do use some form of repeatable agile process for building software applications. Almost any repeatable process is better than none at all. (If you need one I recommend Scrum.)
- Do use a source code control system (svn, cvs, or commercial products).
- Do use a formal bug-tracking system.
- Do have some form of source code peer review.
- Do have coding standards, preferably a consistent set of standards across all applications.
- Do have a repeatable, automated build system for your applications.
- Do have an automated testing system (regression tests) for your applications.
- Do have some mix of experienced developers (who are good and experts in these practices) and relatively new developers.
- Always keep your applications in a running, demonstrable state.
Labels:
Best Practices
Subscribe to:
Posts (Atom)