0% found this document useful (0 votes)
26 views

OOAD Chapter 5 Programming Style

The document discusses programming styles, emphasizing the importance of clarity, naming conventions, control constructs, and information hiding in coding practices. It contrasts non-object-oriented programming with object-oriented programming, highlighting their different approaches and characteristics. Additionally, it covers object-oriented databases, their advantages and drawbacks, and provides examples of various object databases and their features.

Uploaded by

ptpt8091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views

OOAD Chapter 5 Programming Style

The document discusses programming styles, emphasizing the importance of clarity, naming conventions, control constructs, and information hiding in coding practices. It contrasts non-object-oriented programming with object-oriented programming, highlighting their different approaches and characteristics. Additionally, it covers object-oriented databases, their advantages and drawbacks, and provides examples of various object databases and their features.

Uploaded by

ptpt8091
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Chapter V

OOAD
 Programming style refers to the technique used in writing
the source code for a computer program. Most
programming styles are designed to help programmers
quickly read and understands the program as well as avoid
making errors. (Older programming styles also focused on
conserving screen space.) A good coding style can
overcome the many deficiencies of a first programming
language, while poor style can defeat the intent of an
excellent language.

 The goal of good programming style is to provide


understandable, straightforward, elegant code. The
programming style used in a various program may be
derived from the coding standards or code conventions of
a company or other computing organization, as well as the
preferences of the actual programmer.
 Some general rules or guidelines in respect of programming
style:

 1. Clarity and simplicity of Expression: The programs should be


designed in such a manner so that the objectives of the program
is clear.

 2. Naming: In a program, you are required to name the module,


processes, and variable, and so on. Care should be taken that the
naming style should not be cryptic and non-representative.
 For Example: a = 3.14 * r * r
area_of_circle = 3.14 * radius * radius;

 3. Control Constructs: It is desirable that as much as a possible


single entry and single exit constructs used.

 4. Information hiding: The information secured in the data


structures should be hidden from the rest of the system where
possible. Information hiding can decrease the coupling between
modules and make the system more maintainable.
 5. Nesting: Deep nesting of loops and conditions greatly
harm the static and dynamic behavior of a program. It also
becomes difficult to understand the program logic, so it is
desirable to avoid deep nesting.

 6. User-defined types: Make heavy use of user-defined


data types like enum, class, structure, and union. These
data types make your program code easy to write and easy
to understand.

 7. Module size: The module size should be uniform. The


size of the module should not be too big or too small. If
the module size is too large, it is not generally functionally
cohesive. If the module size is too small, it leads to
unnecessary overheads.

 8. Module Interface: A module with a complex interface


should be carefully examined.

 9. Side-effects: When a module is invoked, it sometimes


has a side effect of modifying the program state. Such
side-effect should be avoided where as possible.
Non object Oriented Programming Object Oriented Programming

In Non object Oriented programming, In object oriented programming,


program is divided into small parts program is divided into small parts
called functions. called objects.

Non object Oriented programming Object oriented programming


follows top down approach. follows bottom up approach.

Object oriented programming have


There is no access specifier in Non
access specifiers like private, public,
object Oriented programming.
protected etc.
Adding new data and function is not
Adding new data and function is easy.
easy.

Non object Oriented programming Object oriented programming


does not have any proper way for provides data hiding so it is more
hiding data so it is less secure. secure.

In Non object Oriented programming, Overloading is possible in object


overloading is not possible. oriented programming.

In Non object Oriented programming, In object oriented programming, data


function is more important than data. is more important than function.

Non object Oriented programming is Object oriented programming is


based on unreal world. based on real world.

Examples: Java, C++, C#, Python, R,


PHP, Visual Basic.NET,
Examples: C, FORTRAN, Pascal, Basic JavaScript, Ruby, Perl, Object Pascal,
etc. Objective-C, Dart, Swift, Scala, Kotlin,
Common Lisp, MATLAB, and
Smalltalk,etc.

 A database is a data storage. A software system
that is used to manage databases is called a
database management system (DBMS). There are
many types of database management systems
such as hierarchical, network, relational, object-
oriented, graph, and document.

 An object-oriented database (OODBMS) or object


database management system (ODBMS) is a
database that is based on object-oriented
programming (OOP). The data is represented and
stored in the form of objects.
 Object-Oriented Database

 Object database management systems (ODBMSs) are based
on objects in object-oriented programing (OOP). In OOP,
an entity is represented as an object and objects are
stored in memory. Objects have members such as fields,
properties, and methods. Objects also have a life cycle that
includes the creation of an object, use of an object, and
deletion of an object.

 OOP has key characteristics, encapsulation, inheritance,


and polymorphism. Today, there are many popular OOP
languages such as C++, Java, C#, Ruby, Python, JavaScript,
and Perl.

 Object databases are commonly used in applications that


require high performance, calculations, and faster results.
Some of the common applications that use object
databases are real-time systems, architectural &
engineering for 3D modeling, telecommunications, and
scientific products, molecular science, and astronomy.

 Advantages of Object Databases

 ODBMS provide persistent storage to objects. Imagine creating
objects in your program and saving them as it is in a database
and reading back from the database.

 In a typical relational database, the program data is stored in
rows and columns. To store and read that data and convert it
into program objects in memory requires reading data, loading
data into objects, and storing it in memory. Imagine creating a
class in your program and saving it as it is in a database, reading
back and start using it again.

 In typical RDBMS, there is a layer of object-relational mapping
that maps database schemas with objects in code. Reading and
mapping an object database data to the objects is direct without
any API or tool. Hence faster data access and better performance.

 Some object database can be used in multiple languages. For
example, Gemstone database supports C++, Smalltalk and Java
programming languages
 Drawbacks of Object Databases

 Object databases are not as popular as RDBMS.

 It is difficult to find object DB developers.

 Not many programming languages support


object databases.

 RDBMS have SQL as a standard query language.


 Object databases do not have a standard.

 Object databases are difficult to learn for non-


programmers.
 Following are the some examples of Object
Databases..
 1.Cache
 InterSystems’s Caché is a high-performance
object database. Caché database engine is a set
of services including data storage, concurrency
management, transactions, and process
management.

 Caché is also a full-featured relational database.
All the data within a Caché database is available
as true relational tables and can be queried and
modified using standard SQL via ODBC, JDBC, or
object methods. Caché is one of the fastest, most
reliable, and most scalable relational databases.
 Cache offers the following features

 The ability to model data as objects.

 Reduces the complexity of relational modeling,

 A simpler, object-based concurrency model.

 User-defined data types.

 The ability to take advantage of methods and inheritance,


including polymorphism, within the database engine

 Object-extensions for SQL to handle object identity and


relationships.

 The ability to intermix SQL and object-based access within a


single application, using each for what they are best suited.

 Control over the physical layout and clustering used to store data
in order to ensure the maximum performance for applications.
 Cache offers a broad set of tools, which include,
 ObjectScript, the language in which most of Caché is written.

 A well-developed, built-in security model

 A suite of technologies and tools that provide rapid development for database and
web applications

 Native, object-based XML and web services support

 Device support (such as files, TCP/IP, printers)

 Automatic interoperability via Java, JDBC, ActiveX, .NET, C++, ODBC, XML, SOAP,
Perl, Python, and more

 Support for common Internet protocols: POP3, SMTP, MIME, FTP, and so on

 A reusable user portal for your end users

 Support for analyzing unstructured data

 Support for Business Intelligence (BI)

 Built-in testing facilities


 2.ConceptBase

 ConceptBase.cc is a multi-user deductive database system with
an object-oriented (data, class, metaclass, meta-metaclass, etc.)
makes it a powerful tool for meta-modeling and engineering of
customized modeling languages. The system is accompanied by
a highly configurable graphical user interface that builds upon
the logic-based features of the ConceptBase.cc server.

 ConceptBase.cc is available for Linux, Windows, and Mac OS-X.
There is also a pre-configured virtual appliance that contains the
executable system plus its sources plus the tools to compile
them. The system is distributed under a FreeBSD-style license.

 3.Db4o

 db4o is the world's leading open-source object database for Java
and .NET. It leverages fast native object persistence, ACID
transactions, query-by-example, object query API, automatic
class schema evolution, small size,etc.
 4.ObjectDB

 ObjectDB is a powerful Object-Oriented Database Management


System (ODBMS). It is compact, reliable, easy to use and
extremely fast. ObjectDB provides all the standard database
management services (storage and retrieval, transactions, lock
management, query processing, etc.) but in a way that makes
development easier and applications faster.

 ObjectDB Database Key Features

 100% pure Java Object-Oriented Database Management System


No proprietary API - managed only by standard Java APIs.
 Extremely fast - faster than any other JPA / JDO product.
 Suitable for database files ranging from kilobytes to terabytes.
 Supports both Client-Server mode and Embedded mode.
 Single JAR with no external dependencies.
 The database is stored as a single file.
 Advanced querying and indexing capabilities.
 Effective in heavy loaded multi-user environments.
 Can easily be embedded in applications of any type and size.
 Tested with Tomcat, Jetty, GlassFish, JBoss, and Spring.
 5.ObjectDatabase++
 ObjectDatabase++ (ODBPP) is an embeddable object-oriented database
designed for server applications that require minimal external
maintenance. It is written in C++ as a real-time ISAM level database with
the ability to auto recover from system crashes while maintaining
database integrity.

 6.Objectivity/DB
 Objectivity/DB is a scalable, high performance, distributed Object
Database (ODBMS). It is extremely good at handling complex data, where
there are many types of connections between objects and many variants.

 Objectivity/DB runs on 32 or 64-bit processors running Linux, Mac OS X,
UNIX (Oracle Solaris) or Windows.There are C++, C#, Java and Python
APIs.

 All platform and language combinations are interoperable. For example,
objects stored by a program using C++ on Linux can be read by a C#
program on Windows and a Java program on Mac OS X.

 Objectivity/DB generally runs on POSIX file systems, but there are
plugins that can be modified for other storage infrastructure.

 Objectivity/DB client programs can be configured to run on a standalone
laptop, networked workgroups, large clusters or in grids or clouds with
no changes to the application code.
 7.Versant Object Database

 Versant Object-Oriented Database is an object database that
supports native object persistence and used to build complex
and high-performance data management systems.

 Key Benefits
 Real-time analytical performance
 Big Data management
 Cut development time by up to 40%
 Significantly lower total ownership cost
 High availability

 8.WakandaDB

 WakandaDB is an object database and provides a native API to
access interconnected DataClasses defined in Server-Side
JavaScript. WakandaDB is the server within Wakanda which
includes a dedicated, but not mandatory, Ajax Framework, and a
dedicated IDE.

 9.ObjectStore

 ObjectStore is an enterprise object-oriented database
management system for C++ and Java.

 ObjectStore delivers multi-fold performance improvement by
eliminating the middleware requirement to map and convert
application objects into flat relational rows by directly persisting
objects within an application into an object store.

 ObjectStore eliminates need to flatten complex data for
consumption in your application logic reducing the overhead of
using a translation layer that converts complex objects into flat
objects, dramatically improving performance and often entirely
eliminating the need to manage a relational database system.

 ObjectStore is OO storage that directly integrates with Java or
C++ applications and treats memory and persistent storage as
one – improving the performance of application logic while fully
maintaining ACID compliance against the transactional and
distributed load.
 Generally, Computer animation is a visual digital display
technology that processes the moving images on screen.
In simple words, it can be put or defined as the art or
power of giving life, energy and emotions etc. to any non-
living or inanimate object via computers. It can be
presented in form of any video or movie. Computer
animation has the ability to make any dead image alive.
The key/main concept behind computer animation is to
play the defined images at a faster rate to fool the viewer
so that the viewer should interpret those images as a
continuous motion of images.

 Computer Animation is a sub-part or say small part of


computer graphics and animation. Nowadays, animation
can be seen in many area around us. It is used in a lot of
movies, films and games, education, e-commerce,
computer art, training etc. It is a big part of entertainment
area as most of the sets and background is all build up
through animation.
 Applications of Computer Animation
 Methods/Techniques:
 1.Frame by Frame (Traditional Method):
Earlier, in traditional method, animation was
done by hands because of the absence of the
computer-aided drawing facilities. And, these
traditional method required a lot of effort for
even making a short video because of the fact
that every second of animation requires 24
frames to process.

 2.Procedural:
In Procedural method, set of rules are used to
animate the objects. Animator defines or specify
the initial rules and procedure to process and
later runs simulations. Many of the times rules or
procedure are based on real world.
 3.Behavioral:
According to this method/technique, to a certain
extent the character or object specifies
/determines it’s own actions which helps / allows
the character to improve later, and in turn, it
frees the animator in determining each and every
details of the character’s motion.

 4.Key Framing:
A key frame in computer animation is a frame
where we define changes in an animation.
According to key framing, a storyboard
requirement is must as the animator/artist draws
the major frames of animation from it. In key
framing, character’s or object’s key position are
the must and need to be defined by the animator,
because the missing frames are filled in those
key position via computer automatically.
5.Motion Capture:
This method of animation uses the live action/motion
footage of a living human character which is recorded
to the computer via video cameras and markers and
later, that action or motion is used/applied to animate
the character which gives the real feel to the viewers as
if the real human character has been animated. Motion
Capture is quite famous among the animators because
of the fact that the human action or motion can be
captured with relative ease.

6. Dynamics:
In this method, simulations are used in order to
produce a quite different sequence while maintaining
the physical reality. Physics’s laws are used in
simulations to create the motion of pictures
/characters. High level of interactivity can be achieved
in this method, via the use of real-time simulations,
where a real person performs the action or motions of
a simulated character.
 The component based object oriented design in power
 distribution system is based on the principles of object
 oriented analysis and design (OOAD) . The first part of
 OOAD is object oriented analysis and the second part is
 object oriented design. The requirements needed for the
 problem domain has been identified by the first part and
 designed it in the second part. The component based
 methods are used to perform the object oriented activities
 in an efficient form. By the principles of component based
 object oriented concepts, the problem domain can provide
 reusability, maintainability and flexibility. The component
 based method enable fast maintainable and reusable
 components. Components are highly reusable units of
 functionality. The design method provide excellent support
 for the successful distribution of power to the specified
 regions.
 This paper focuses on the component based
object oriented design for the concept of
power distribution system. The power
distribution system is classified into three
categories: i) Residential, ii) Agricultural, iii)
Commercial
 DESIGN CONCEPTS OF POWER DISTRIBUTION SYSTEM

 The power that is distributed to the substation is identified


 in the analysis phase. The requirements needed to distribute
 the power from distribution system to the substation are
 analyzed. The Fig.1 shows the architecture of
 substation. The substation receives 33kV of power from the
 distribution system . This 33kV is stepped down to
 11kV and distributed to the base station computer. The
 stepped down activities is analyzed in the analysis phase.
 From the base station computer the power is again
 stepped to 415 V to agriculture, commercial and residential
 regions.

 Object oriented analysis requires domain knowledge and


 expertise in object oriented concepts. Hence, there is a need
 for both a domain expert and an object oriented analysis
 Expert.
 In the design phase, consider each substation divisions as
 an object. The 11kV power is again stepped down to 415 V
 and 240V in the base station and distribute to the three
 regions.
 The 415V is taken as a 3 phase supply and
240V is taken as a single phase supply.
Evaluate the power distributed for the three
different regions by identifying the current
and voltage. This method concentrates only
on the distribution of power for 3 phase
supply. The power distribution system itself
can be represented as an object, since it is a
composition of other physically existing
objects. All the software object has primary
attributes that represent the physical features
of the object, data accessing and data
processing methods that describe the
interfaces of the object. The substation and
its regions are taken as the components.
 Object oriented programming is the final
phase of object oriented methodology in
which implementation is carried out.
 Classes have been developed for every
designed objects using bottom up approach,
which gives an ease of implementation. The
classes are used for the inheritance process
and is used to implement the specialization
 relationship.
 Web APIs
 Microservices, the second and more complete type of
Service-Oriented Architecture (SOA), allow us to
decompose our logic into reusable services that are
accessed via open network protocols. This is crystallizing
into an accepted convention of HTTP. The code for our
microservice, i.e. what’s behind the API, doesn’t matter to
the outside world. Indeed, programming web APIs is
functional programming in its very nature.

 This is partly why JavaScript is such a good fit for server-


side code. Whilst the language has been updated to
incorporate many OO features such as classes, the
language is functional at its core. To define an API in
JavaScript is really just to map a function onto a route. And
since functions are first-class citizens in JavaScript.
 By contrast, take a look at some of the
implementations of service interfaces in OO
languages (e.g. .svc and .asmx in C#) and
you’ll notice that they have shoehorned in an
OO interface/class structure when in fact an
API call invokes a function. You find that to
even create a “Hello World” you end up with a
binary of an amazing size.

 Look at the size of a Node.js JavaScript “Hello


World” app. A kilobyte? It’s faster too. A lot
faster. Functional programming and
functional languages definitely have the edge
in this area of programming
 Serverless Functions
 How many of you have used AWS Lambda, or its
equivalents (Google Cloud Functions, Azure Cloud
Functions). This is a new area for programming, which is
coming into being because of cloud platforms. Essentially,
serverless functions are pieces of code that are invoked by
an event. However, they don’t have a permanent host
hence the “serverless”.

 When an event trigger occurs, such as a message being


placed on a queue, the cloud platform spins up an
instance to run the code that handles the event. When it’s
finished, the instance can terminate and hence free up
resources. This is an amazingly powerful concept because
it really is getting as close as possible to a pay-as-you-
use model.

 And the programming paradigm? Functional.


Dynamic. You invoke a function to handle the event and
the data that comes with it. Ideal language for this type of
scenario? Python.
 UI
 User interface (UI) is a very interesting area from a
technology point of view. UI is the area where the real
pace of change is felt. You only need to go back a
couple of versions in many pieces of software (or
websites) and you will cringe at the clunky interface
you used to take for granted. UI sells.

 Good UIs are stateful too, and hence they lend


themselves to OO design. Browser-based UIs were
something of an exception, as postbacks to the
server to refresh HTML content were effectively
functional web API calls. The trend towards single
page applications and frameworks such
as ReactJS and Angular have meant that even
browser-based UIs are now falling in line with OO
programming methods. Ironically, using JavaScript.

 I see UI as one of the last great outposts of OO


programming.
 Frameworks
 The open source movement, combined with open
package repos and package managers have
massively impacted on the way we use code.
Software is built on software, and if a problem
has been solved before, well you’d be fool not to
reuse the solution.
 In terms of language and programming paradigm
the jury is out on this one. There’s such a split in
the packages that are out there that it’s hard to
make predictions. There is a ton of functional
JavaScript code out there, just as almost
everything is probably OO.
 This is an interesting one to watch. Frameworks
and framework extensibility were a case study for
OO design patterns. Now, the functional world
has found its own patterns for extensibility and
reuse.
 Other Trends
 The trend away from installed on-premise software to
Software-as-a-Service (SaaS) is only going to accelerate. This
will build on the points above, but the real demise will be felt
when companies are decommissioning system after system
from their own datacenters to avoid having to maintain and
support them.
 Add to this the shift to cloud. Do the math – the cloud
represents huge savings and huge opportunities if embraced
correctly. Less so for pure lift and shift of on-premise
systems, but organizations that are architected from the
ground-up to take advantage of cloud and SaaS will have
huge competitive advantage. Again, this is more of the same:
APIs, Serverless Functions, UI.

 If you look at what’s going on there you find a lot of scripting


going on. Python’s very strong, but so is Ruby. Bash is very
procedural, PowerShell mostly procedural but also made to
support .Net. Python is going to win big in this area over the
next few years. Python is also widely adopted within Google.
 Summary

 This has been a whirlwind tour of a big subject area,


sprinkled with a thin layer of thoughts.
 I think the big growth areas in programming are
going to be:

 Further decomposition into microservices and APIs.

 Serverless functions to handle asynchronous


processing.

 SaaS applications replacing installed applications.

 Of these, I think the first two will be dominated by


functional programming and dynamic languages

You might also like