principles of object-oriented software development
DESCRIPTION
Principles of Object-Oriented Software Development. Hello (CORBA) Universe. Hello (CORBA) Universe. Introduction Interface The broker abstraction C++ Realization Java Realization Prolog Realization Configuration Conclusions. Hello (CORBA) Universe. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/1.jpg)
Principles of Object-Oriented Software Development
Hello (CORBA) Universe
![Page 2: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/2.jpg)
Hello (CORBA) Universe
Introduction Interface The broker abstraction C++ Realization Java Realization Prolog Realization Configuration Conclusions
![Page 3: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/3.jpg)
Hello (CORBA) Universe
• platform-independent
• language-independent
• server -- C++, Java, Prolog, ...
• client -- C++, Java, Prolog, ...
• 9 combinations -- test.sh
![Page 4: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/4.jpg)
The Interface - IDL
module universe { universe.idl
interface world { world
void hello(); void ask(in string x); string tell(); oneway void halt(); };};
![Page 5: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/5.jpg)
C++ Realization
• broker -- access to ORB and BOA
• client -- needs ORB only
• server -- needs access to BOA
• implementation -- world-srv.h world-srv.c
![Page 6: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/6.jpg)
C++ broker -- class
class broker { broker.h public: broker(); void init(int& argc, char**& argv, int fl=0); 1 = client
int operator()(); to run the server char* ref(corba::object* x); object_to_string corba::object* ref(const char* s); string_to object corba::object* object(const char* file); get object IOR file void refout(const char* f, corba::object* x); IOR to file };
![Page 7: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/7.jpg)
C++ broker -- implementation
broker::broker() { } broker.c
void broker::init(int& argc, char**& argv, int fl=0) { _orb = CORBA_ORB_init(argc, argv); if (!fl) _boa = _orb -> BOA_init(argc, argv); } } int broker::operator()() { _boa -> impl_is_ready(CORBA_ImplementationDef::_nil()); }
![Page 8: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/8.jpg)
int main(int argc, char* argv[], char*[]) { client.c broker* _broker = new broker(); get yourself a broker try { _broker->init(argc,argv); initialize broker
corba::object* obj = _broker->object("world.ref"); universe_world_var world = universe_world::_narrow(obj); { some object invocations world -> hello(); world -> ask("How are Clinton's affairs?"); cout << "client:" << world->tell() << endl; } } catch(corba::exception ex) { ... } }
![Page 9: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/9.jpg)
int main(int argc, char* argv[], char*[]) server.c { broker* _broker = new broker(); get yourself a broker try { _broker->init(argc,argv); initialize orb and boa
universe_world_var p = new universe_world_srv; _broker->refout("world.ref", p); write identity
_broker->operator()(); run the the world
} catch(corba::exception& ex) { ... } }
![Page 10: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/10.jpg)
void universe_world_srv::hello() { world_srv.c cout << "Hello World!" << endl; } void universe_world_srv::ask(const char* s) { cout << "Asking: " << s << endl; } char* universe_world_srv::tell() { char result[] = "ok"; CORBA_String_var s = (const char*) result; return s._retn(); } void universe_world_srv::halt() { exit(0); }
![Page 11: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/11.jpg)
Java Realization
• broker -- contact ORB and BOA
• client -- connect to server
• server -- announce server object
• implementation -- world_srv.java
![Page 12: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/12.jpg)
import org.omg.CORBA.*; broker.java
import java.io.*; public class broker { boolean _fl = false; java.applet.Applet _applet = null; public broker() { } public broker(boolean fl) { _fl = fl; } public broker(java.applet.Applet x) { _applet = x; init(null); }
![Page 13: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/13.jpg)
public void init(String[] args) { if (_applet == null) { _orb = ORB.init(args,new java.util.Properties()); if (!_fl) _boa = _orb.BOA_init(args,new java.util.Properties()); } else _orb = ORB.init(_applet, null); } public int operator() { run -- server-only
if (!_fl) _boa.impl_is_ready(null); return 0; // OK } .... }; Java -- broker
![Page 14: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/14.jpg)
package universe; import org.omg.CORBA.*; client.java import java.io.*; import hush.broker; see broker.java
public class client { public static void main(String args[]) { broker _broker = new broker(true); // true means client only try { _broker.init(args); init orb org.omg.CORBA.Object obj = _broker.object("world.ref"); world world = worldHelper.narrow(obj); if (world == null) throw new RuntimeException(); System.out.println("Enter 'h' for hello or 'x' for exit:"); ... // do some requests to the world } catch(...) { ... } } };
![Page 15: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/15.jpg)
package universe; server.java import org.omg.CORBA.*; import java.io.*; import hush.broker; // see broker.java public class server { public static void main(String args[]) { broker _broker = new broker(); try { _broker.init(args); create orb en boa; world_srv p = new world_srv(); create impl object _broker.refout("world.ref",p); write ref
![Page 16: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/16.jpg)
// create world.htm _broker.html("world.htm",p, " code=universe/applet.class " + "width=500 height=300"); _broker.operator(); // run == boa.impl_is_ready(null); } catch(SystemException ex) { _broker.print(ex); System.exit(1); } System.exit(0); } }
Java -- server
![Page 17: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/17.jpg)
package universe; world_srv.java import org.omg.CORBA.*; public class world_srv extends _worldImplBase { public void hello() { System.out.println("Hello World!"); } public void ask(String msg) { System.out.println(msg); } public String tell() { String s = new String("ok"); return s; } public void halt() { System.exit(0); }
![Page 18: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/18.jpg)
Prolog Realization
• broker -- mediating service
• client -- get object reference
• server -- provide implementation
• implementation -- universe.pl
![Page 19: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/19.jpg)
broker(client(M:F)) :- broker.pl
... corba_initialize_orb([], _), factory(F). gives a handle to the server object
![Page 20: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/20.jpg)
broker(server(M:I)) :- ... corba_initialize_server([server,server(test), timeout(infinite)],Server), ... create server object
G =.. [_Create,_Server,Self], call(G), corba_object_to_string(Self,IOR), open(IORFile,write,Fd), write reference to file format(Fd,'string',[IOR]), close(Fd), corba_main_loop(Server). enter main loop
Prolog -- broker
![Page 21: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/21.jpg)
client.pl
:- use_module(universe). see universe.pl
:- [broker]. include broker
main :- broker(client(universe:F)), initialize the broker assert(client(factory(F))), run. run :- h, ask('What is the state of Clinton s affairs?'), write('Type h to say hallo, x to quit.'),nl.
![Page 22: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/22.jpg)
ask(X) :- client(factory(F)), write(client(ask(X))),nl, world_ask(F,X), world_tell(F,R), write(client(ans(R))),nl. h :- client(factory(F)), world_hello(F). q :- client(factory(F)), world_halt(F), halt. x :- halt.
Prolog -- client
![Page 23: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/23.jpg)
:- [broker]. server.pl
main :- broker(server(universe:world)).
Prolog -- server
![Page 24: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/24.jpg)
:- module('universe',[]). universe.pl
world_hello(_Self) :- write('Hello World'),nl. world_ask(_Self, X) :- write(asking(X)), nl. world_tell(_Self,Y) :- Y = 'logically, ok', write(telling(Y)),nl. world_halt(_Self) :- halt.
Prolog -- implementation
![Page 25: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/25.jpg)
Configure, make and test
• Makefile
• corba.cfg
• test.sh
![Page 26: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/26.jpg)
Conclusions
• CORBA is ripe to be exploited in OO -- the practicum
• the broker is a useful abstraction
• forget about the wiring - concentrate on application logic
![Page 27: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/27.jpg)
Idioms and Patterns
Introduction
Polymorphism Idioms in hush A catalogue of design patterns Event-driven computation
Summary Q/A Literature
![Page 28: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/28.jpg)
Summary
![Page 29: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/29.jpg)
Questions1.How would you characterize OOP and what, in your opinion, is the motivation underlying the introduction of OOP? 2.Characterize the most important features of OOP. 3.Explain the meaning of the phrase "object orientation reduces the complexity of programming." 4.How would you characterize contracts? Why are contracts important? 5.How is OOP related to programming languages? 6.What classes of languages support OOP features? Explain. 7.What influence is an object-oriented approach said to have on the software life-cycle? What is your own opinion? Discuss the problem of maintenance. 8.How would you characterize software quality? 9.Mention a number of object-oriented programming languages, and give a brief characterization. 10.What do you see as the major challenges for research in object-orientation?
![Page 30: Principles of Object-Oriented Software Development](https://reader036.vdocuments.site/reader036/viewer/2022062309/56814fbb550346895dbd74ea/html5/thumbnails/30.jpg)
Further reading
Nowadays there are many books that may serve as a starting point for reading about OO. Dependent on your interest, you may look at [Surviving], which treats issues of OO project management, [Meyer97], which gives an extensive introduction to design by contract and programming in Eiffel, or [Fowler97], which gives a succinct introduction to UML. Alternatively, you may take one of the introductory programming books for Java, from which you will almost certainly learn something about OO as well.