Presentation is loading. Please wait.

Presentation is loading. Please wait.

Plan for today Refactoring and Design Patterns

Similar presentations


Presentation on theme: "Plan for today Refactoring and Design Patterns"— Presentation transcript:

1 Plan for today Refactoring and Design Patterns
What is a Quiz How do you create quiz, get quiz, use quiz What is the model, what is the view Android specific, OO Specific Understanding vocabulary, getting projects done, working in pairs and/or groups Compsci 290 compared to IRL

2 Java and Object-Oriented Concepts
What is a class? When to use inheritance? Class encapsulates state and behavior State is instance variables Behavior is public/exported methods: API Inheritance models "is-a" Liskov Substitution Principle Given pointer/reference to Foo, replace with any subtype/subclass and everything works (beware of Rectangle/Square)

3 Quiz Differences What are the differences in 2 and 4 question quizzes from Model perspective A quiz is not part of a view here, it's a model/part of a model Is this state difference of a behavior difference? How might you capture the differences? Subclassing? Changing public methods of Quiz/Question?

4 Conceptual and Practical Refactoring
Design and Implementation: iterative Think first, code later? Code first, think later? Think, code, think, code, … repeat until done What is a Quiz? Think about this from both programmatic and non-programmatic views Do programs model real-world expectations?

5 Refactoring Ideas Question class: state and behavior What is a Quiz?
What is a question? Ideas for two/four answer question Who (what) creates a Question? What is a Quiz? What was a QuizGenerator in original program, what are flaws with that design? What might be source of quiz? Should user have choice of quizzes? How?

6 Design Pattern In software engineering, a software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design. It is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Design patterns are formalized best practices that the programmer can use to solve common problems when designing an application or system.

7 Personal Pattern Odyssey

8 Creational Patterns Factory: What kind of Quiz will we use, source of questions rather than behavior, e.g., JSONQuiz, SQLQuiz, … Creation of quiz types deferred to factory, ask the factory for the quiz Abstract Factory and Singleton classes What is source of factory, e.g., web-based, SQL-based, internal Don't permit creation, e.g., singleton class

9 What about the View? How will we display multiple answers to user as part of Quiz? Some concepts and ideas that might help? Android concept of Fragment: part of Activity, but not a separate Screen, e.g., swappable on the same screen Android concept of ListView, e.g., see documentation: Simple? Just create two or four buttons?

10 Future Considerations
Questions displayed as images rather than strings: design and coding impact? How do you know what correct answer is? Do you query button for state? Other mechanisms? Source of Quiz Questions Once Quiz created, is question the same? Is ImageQuestion different? Is QuizGenerator/QuizFactory Different?

11 Loading Quizzes/Questions
What might issues be in creating or using different Quiz/Questions sources, e.g., web, sql, other? How will you manage some of these issues? How will you know what Android provides versus what you create yourself? Loaders:

12 Adding Functionality to QuizMaster
Branch is multi-questions Walk through refactoring changes to Quiz, Question, QuizGenerator Java-isms Static initializers: purpose Android-isms Static naming conventions What's left? Many things 


Download ppt "Plan for today Refactoring and Design Patterns"

Similar presentations


Ads by Google