1 / 22

Structured Programming and UML Overview

Understand the fundamentals of Java programming, including variables, static methods, arrays, and classes. Learn how to use UML diagrams to design and structure your Java programs effectively.

rlyon
Download Presentation

Structured Programming and UML Overview

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Structured ProgrammingandUML Overview Session 2 LBSC 790 / INFM 718B Building the Human-Computer Interface

  2. Agenda • Questions • The big picture • Making java • UML overview

  3. ? ? The Big Picture Input Output

  4. Language Learning • Learn some words • Put those words together in simple ways • Examine to broaden your understanding • Create to deepen your mastery • Repeat until fluent

  5. Variables • Hold a reference to an object • Or the value of a primitive data type • Must be declared • Generally, done at the beginning of: • Classes (“instance variables”) • Methods (“local variables”) • Inline declarations are allowed • Local variables must be initialized!

  6. Static • Exist without using “new” • Referred to by the class name, not the object • Static variables are “constants” • Static methods can be invoked with no instance • This is how the main method in an application works • Static methods can’t refer to instance variables

  7. Arrays in Java • A set of elements • For example, the number of days in each month • Each element is assigned an index • A number used to refer to that element • For example, x[4] is the fifth element - count from zero • Arrays and loops work naturally together

  8. Methods in Java • Defining a method int multiplyNumbers (a, b){return a*b;} • Argument values are local to the method • Explicitly invoking a method multiplyNumbers(b, 7); • Events invoke a method in response to a stimulus • Mouse click, mouseover, resize window, …

  9. Java Objects • Java objects represent specific things • “new” operator “instantiates” an object • By calling a “constructor” method • “Garbage collection” destroys objects

  10. Java Classes • Java classes represent types of things • Can be thought of as blueprints for objects • Classes = state + actions • State is represented by variables • Actions are represented by methods • Scope rules support abstract thinking • Public: can be used from other classes • Private: can only be seen in the class

  11. Java By Example • Identify the needed types of objects • For each object type (“class”): • Represent the state using variables • Represent the actions using methods • Write the java code • Test it using a main method • Test the entire system

  12. Library Circulation Example • A library is a collection of books • Initially, assume just one copy of each book • Users can check to see if a book they want is available • Users can check out and check in books

  13. Exercise • Read the Book class • Available on the session 2 notes page • Create the Library class • Test the two together • Revise the book class for multiple copies • Test the improved system

  14. How variables are named How arrays are used How strings are used Modularity of methods How errors are handled How methods are invoked How arguments work How layout helps reading How results are passed How scope is managed How boolean flags are used How output is created How classes are defined How applications are invoked Some Things to Pay Attention To

  15. Unified Modeling Language • Systems can get more complex than people can comprehend all at once • Key idea: Progressive refinement • Carve the problem into pieces • Carve each piece into smaller pieces • When the pieces are small enough, code them • UML provides a formalism for doing this • But it does not provide the process

  16. Getting to the Object Structure • Capturing the big picture • Use case diagram (interactions with the world) • Narrative • Scenarios (examples to provoke thinking) • Designing the object structure • Class diagram (“entity-relationship” diagram) • Object diagram (used to show examples)

  17. Specifying Behavior • Represent a candidate workflow • Activity diagram (a “flowchart”) • Represent object interactions for a scenario • Collaboration diagram (object-based depiction) • Sequence diagram (time-based depiction) • Represent event-object interactions • Statechart diagram (a “finite state machine”)

  18. Good Uses for UML • Focusing your attention • Design from the outside in • Representing partial understanding • Says what you know, silent otherwise • Validate that understanding • Structuring communication with stakeholders

  19. Avoiding UML Pitfalls • Don’t sweat the notation too much • The key is to be clear about what you mean! • Don’t try to make massive conceptual leaps • Leverage abstraction encapsulation • Don’t get to attached to your first design • Goal is to find weaknesses in your understanding

  20. First Steps in UML • Examine the FlightFinder • http://www.glue.umd.edu/~oard/spacea/ff/ • Identify the key actors • Identify the use cases • Draw a use case diagram

  21. Show and Tell • What cool resources have you found? • Books and Web sites? • What new Java tricks have you learned? • What do you need to know to make progress?

  22. Muddiest Point On a blank sheet of paper, write a single sentence that will convey to me what you found to be the most confusing thing that was discussed during today’s class.

More Related