* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Download Lecture 10
Comment (computer programming) wikipedia , lookup
Software quality wikipedia , lookup
Dependency injection wikipedia , lookup
Scala (programming language) wikipedia , lookup
Object-oriented programming wikipedia , lookup
Library (computing) wikipedia , lookup
Structured programming wikipedia , lookup
Program optimization wikipedia , lookup
Algorithmic skeleton wikipedia , lookup
Object-relational impedance mismatch wikipedia , lookup
Software bug wikipedia , lookup
Go (programming language) wikipedia , lookup
.NET Framework wikipedia , lookup
Java (programming language) wikipedia , lookup
C Sharp syntax wikipedia , lookup
Application Interface Specification wikipedia , lookup
Software Construction Lecture 10 Frameworks Agenda & Reading Topics: Frameworks Extensibility Inversion of Control Java Frameworks Advantages & Disadvantages Reading 2 Software framework Wikipedia Frameworks in Java Framework Generic software platform for a certain type of applications Consists of parts that are found in many apps of that type Libraries with APIs (classes with methods etc.) Ready-made extensible programs ("engines") Sometimes also tools (e.g. for development, configuration, content) Often evolved by developing many apps of that type and reusing code more and more Characteristics: 3 Reusable: the parts can be used for many apps of that type Extensible: developers can add their own app-specific code Inversion of Control: framework often calls your code Framework Examples Web Application Frameworks GUI Toolkits 4 Extensibility All frameworks can be extended to cater for app-specific functionality. A framework is intended to be extended to meet the needs of a particular application Common ways to extend a framework: Extension is carried out by sub-classing, overriding methods, and implementing interfaces Plug-ins: framework can load certain extra code in a specific format Within the framework language: 5 Subclassing & overriding methods Implementing interfaces Registering event handlers Inversion of Control A framework employs an inverted flow of control between itself and its clients. When using a framework, one usually just implements a few callback functions or specializes a few classes, and then invokes a single method or procedure. The framework does the rest of the work for you, invoking any necessary client callbacks or methods at the appropriate time and place. i.e. "Don't call us, we'll call you.“, or "Leave the driving to us.“ Example: Java's Swing and AWT classes. 6 They have a huge amount of code to manage the user interface, and there is inversion of control because you start the GUI framework and then wait for it to call your listeners Inversion of Control Traditional Program Execution The app has control over the execution flow, calling library code when it needs to. 7 Inversion of Control The framework has control over the execution flow, calling app code for app-specific behavior. Inversion of Control Example: Java Applets 8 What is Java Frameworks? Frameworks are large bodies (usually many classes) of prewritten code to which you add your own code to solve a problem in a specific domain. In Java technology there are so many frameworks that helps the programmers to build complex applications easily. Examples: GUI Framework: eg Java's Swing and AWT classes Collection Framework/library 9 It is a unified architecture for representing and manipulating collections It contains Interfaces, Implementations and algorithms Collections Framework The Java Collections Framework provides the following benefits: Reduces programming effort Increases program speed and quality It provides high-performance, high-quality implementations of useful data structures and algorithms Fosters software reuse 10 Concentrate on the important parts of your program rather than on the low-level "plumbing" required to make it work. New data structures that conform to the standard collection interfaces are by nature reusable. The same goes for new algorithms that operate on objects that implement these interfaces. Frameworks VS libraries Framework uses your code because it is usually the framework that is in control. It means the framework controls the sequence and logic of some operation and calls your code to provide certain details You make use of a framework by calling its methods, inheritance, and supplying "callbacks", listeners, etc Note: although sometimes large libraries are referred to as frameworks, this is probably not the most common use of the term. 11 Advantages Reuse can save cost and time Higher level of abstraction Frameworks provides a standard working system through which user can develop the desired module of application or complete application instead of developing lower level details. Developers can devote more time in developing the software requirement Reduced maintenance cost (if the framework is maintained by someone else) 12 Disadvantages Can lead to code bloat Cost of learning a framework Framework may contain lots of unused code May need to use several frameworks Spend more time in assessing the concept, function and its uses in developing the program. Licensing cost (for commercial frameworks) A generic ‘one-size-fits-all’ does not work so efficiently for any specific software. There is need to extend framework with specific code to develop any specific software. 13 GUI Programming Concepts conventional programming: sequence of operations is determined by the program what you want to happen, happens when you want it event-driven programming: sequence of operations is determined by the user’s interaction with the application’s interface anything that can happen, happens at any time GUI Design Concepts a wealth of information creates a poverty of attention - Herbert Simon Principles of good GUI Design IBM's Design concepts Saul Greenberg's HCI pages Tim's HCI notes GUI Programming Concepts in Java Java GUI has components Windows GUI has controls Unix GUI has widgets examples: labels, buttons, check boxes, radio buttons, text input boxes, pull down lists Swing components: JLabel, JButton, JCheckBox, JRadioButton, JTextField, JTextArea, JComboBox Java GUI history: the AWT AWT(JDK 1.0, 1.1): Abstract Window Toolkit package: java.awt, java.awt.event heavyweight components using native GUI system elements used for applets until most browsers supported JRE 1.2 Swing in Java Swing(Java 2, JDK 1.2+) lightweight components that do not rely on the native GUI or OS “look and feel” of Swing components are identical on different platforms can be customized Swing inherits from AWT AWT still used for events, layouts Swing Components in Java advanced GUI support. e.g. drag-and-drop package names: javax.swing, javax.swing.event components inherit from JComponent components are added to a top-level container: JFrame, JDialog, or JApplet.