Programmer-21

Programmer-21

Share

This is for those who love to do programming We provide help you regarding programming languages...such as C#,Android,Java,C , C++ , ASMB and many more

Association Vs Aggregation Vs Composition (Beginning Java forum at Coderanch) 03/02/2016

What is the difference between Association, Aggregation and Composition?

A) The three concepts are closely related, indeed. Aggregation and Composition are actually types of Association. The difference between Inheritance and Association is that :
- Inheritance is "is-a" relationship whereas,
- Association is "has-a" or "owns" relationship.

So lets discuss these.

Aggregation :
----------------
It is referred to as weak type relationship. Lets consider an example to understand this concept.
Lets say we have two entities Department and University. University and Department have "has-a" relationship. i.e University has alot of departments. Or more precisely, one large entity can be composed of multiple small entities.

Class department{}

Class University{
private Department dept;
public void setDept(Department dept){
this.dept = dept;
}

}

Weak relationship means if one entity destroys then it doesn't mean that other will also gets destroy. In above example, you can see that dept is coming from outside as a parameter. It is not instantiating here in this class. Or you can think of a List in University class which keeps adding dept in that list(Aggregating department). So this kind of relationship is referred to as weak relationship or aggregation.

Composition:
-----------------
It is referred to as strong relationship. i,e if one entity destroy then other will also destroy as well.
Lets consider example,

class Room{}
class Building{
Room room = new Room();
}
you can see here room is initializing here and it is not referencing outside somewhere. It means its lifetime is attached to the Building class. If building objects destroy then Room object is also gets destroyed. This kind of relationship is referred to as Strong relationship or Composition.

More Example :
A Library contains students and books. Relationship between library and student is aggregation. Relationship between library and book is composition. A student can exist without a library and therefore it is aggregation. A book cannot exist without a library and therefore its a composition.
This example is taken from http://javapapers.com/oops/association-aggregation-composition-abstraction-generalization-realization-dependency/

For other example, you can refer to this link : http://www.coderanch.com/t/522414/java/java/Association-Aggregation-Composition

Association Vs Aggregation Vs Composition (Beginning Java forum at Coderanch)

04/06/2014

In order to generate key hash you need to follow some easy steps.

1) Download Openssl from: here.

2) Make a openssl folder in C drive

3) Extract Zip files into this openssl folder created in C Drive.

4) Copy the File debug.keystore from .android folder in my case (C:\Users\SYSTEM.android) and paste into JDK bin Folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin)

5) Open command prompt and give the path of JDK Bin folder in my case (C:\Program Files\Java\jdk1.6.0_05\bin).

6) Copy the following code and hit enter

keytool -exportcert -alias androiddebugkey -keystore debug.keystore > c:\openssl\bin\debug.txt

7) Now you need to enter password, Password = android.

8) If you see in openssl Bin folder, you will get a file with the name of debug.txt

9) Now either you can restart command prompt or work with existing command prompt

10) get back to C drive and give the path of openssl Bin folder

11) copy the following code and paste

openssl sha1 -binary debug.txt > debug_sha.txt

12) you will get debug_sha.txt in openssl bin folder

13) Again copy following code and paste

openssl base64 -in debug_sha.txt > debug_base64.txt

14) you will get debug_base64.txt in openssl bin folder

15) open debug_base64.txt file Here is your Key hash.
share|edit|flag

edited Aug 28 '13 at 6:21
Andro Selva
22.6k2088150

answered Sep 13 '12 at 11:35
Vizzz
1,10649

23/03/2014

get data when asyntask finish

//////////////////////////////////////////////////////////////////////////

easy. create interface class.

public interface AsyncResponse {
void processFinish(String output);
}

in your Async class, you need to declare it (interface : AsyncResponse):

public class MyAsyncTask extends AsyncTask{
public AsyncResponse delegate=null;


protected void onPostExecute(String result) {
delegate.processFinish(result);
}

final step: in your main Activity you need to implements interface you created earlier AsyncResponse.

public class MainActivity implements AsyncResponse{
MyAsyncTask asyncTask =new MyAsyncTask();

public void onCreate(Bundle savedInstanceState) {
asyncTask.delegate = this;
}

void processFinish(String output){
//this you will received result fired from async class of onPostExecute(result) method.
}
}

//////////////////////////////////////////////////////////////////////////

http://stackoverflow.com/questions/12575068/how-to-get-the-result-of-onpostexecute-to-main-activity-because-asynctask-is-a

21/07/2013

The Web Api is an http service. we are trying to expose data or functionality over the http protocol.Typically web api are designed to achive broad reach mean as many as client.Client could be browser or any mobile device.Also since every client can understand http protocol thats why it gives a broad reach.

21/07/2013

Web service :
Mean using methods or things reside on internet to perform our operation.such as using converter service to convert meter into miles.
example :
Traditional desktop office applications such as word processors and spreadsheets have been migrated to web applications through services such as Google Apps and Microsoft Office Live.

Web Api:
function that are used to communicate with web application that reside on internet to get desired information.such as twitter api or facebook api that we can use in our app to integrate such web applications in our applications.

20/07/2013

Android development tutorials coming soon..:)

03/07/2013

CONCEPT OF OOPS (Object-Oriented Programming )
CONCEPT OF OOPS -OBJECT ORIENTED PROGRAMMING
What is Abstraction,Encapsulation,Inheritance,Polymorphism?

ABSTRACTION: Abstraction means to show only the necessary details and hiding non essential features. Abstraction is done when we need to inherit from certain class but do not instantiate the objects of that class.
ENCAPSULATION : Encapsulation is wrapping/binding up of data and member functions in single unit.

In simple, abstraction is hiding the implementation and encapsulation is to hide data.

INHERITANCE : Inheritance enables you to create new classes that reuse ,extend and modify the behaviour that is defined in other classes. In simple terms when one class inherit the properties , methods etc. of the other class is known as inheritance. The class whose members are inherited are called base class and other class is known as derived class .

for eg : using system ;
public class baseclass{
public class baseclass( )
{ console.writeline("this is base class constructor");}
public void hello( )
{ console.writeline("this is baseclass");}
}
public class derivedclass: baseclass
{public dervedclass( )
console.writeline("this is derivedconstructor");
}
public static void main( )
{ derivedclass obj = new derivedclass();
obj.hello( );
}
OUTPUT : this is baseclass constructor
this is derived constructor
this is baseclass



POLYMORPHISM : When an object exhibits different behaviour in different situation. In simple way when a message can be processed in different ways/forms .

Polymorphism is of two types : Compile time polymorphism (this is concept
of OVERLOADING).
Runtime Polymorphism : (this is concept of OVERRIDING).

12/04/2013

Todays quesstion for u programmers..:.
what is the difference between (capital S)String and (small s)string data types in C #..?

Want your school to be the top-listed School/college in Karachi?

Click here to claim your Sponsored Listing.

Location

Category

Website

Address


Karachi