View • Attachments (5) • Info
Some basics on UML. Goes over Class inheritance, aggregation, interfaces and has two simple examples of a class and sequence diagram.

Simple example of one class extending another. No attributes or operations recorded. Make note of the solid line with hollow arrow. This is indicative of inheritance. Below is a java code equivalent of the above illustration.
class Superclass {
}
class Subclass extends Superclass {
}

This is an example of how one class can be composed of another and aggregated to other classes. Take AClass for example. AClass aggregates names which is a List of String instances. Notice that the hollow diamond indicates aggregation. This is how we know that AClass aggregates names. The solid diamond indicates composition. This means that List is composed of String instances and only String instances. That is that the two are non-separable in their distinction. Below is a java code equivalent of the above illustration.
public class AClass { public List<String> names; }

The above illustrates what interfaces look like in UML. Notice there's a SuperInterface that is extended by another interface and then implemented by InterfaceImpl. Below is the java code equivalent of the above illustration
public interface SuperInterface { } interface Interface extends SuperInterface { public void execute(); } class InterfaceImpl implements Interface { public void execute() { } }

The above illustration is like your all-in-one example of pretty much everything you can do in a class diagram. There are 2 interfaces Interface1 and Interface2.
There are 2 classes.
You may notice the different symbols. (-,#,+) are access control symbols. Also, there are some style symbols (italics, bold, plain) that should be noticed. Below is the java code equivalent to the above.
interface Interface1 { public String someMethod(); } interface Interface2() { public void execute(); } class abstract Class1 implements Interface1 { public String someMethod() { return null; } public String publicMethod() { return null; } public abstract String publicAbstractMethod(); public abstract String public VirtualMethod(); public static Integer publicClassMethod() { return null; } protected Float protectedMethod() { return null; } private Double privateMethod() { return null; } public void publicMethodWithParams(String name, Integer value) { } } class Class2 extends Class1 implements Interface2 { public void execute() {} public String publicAbstractMethod() { return null; } public String publicVirtualMethod() { return null; } private String privateMember; protected Float protectedMember; public Double publicMember; public static Integer CONSTANT_MEMBER = 10; }

|
Browse Space |
Explore Confluence |
Your Account |
Add Content |