48024 Lecture Notes - Lecture 5: Procedural Programming
Study 5: Classes
• Procedural programming is where you work with various procedures.
• It is difficult to use procedural programming on a large scale, and this is where an
object oriented approach is best.
• Groups code into objects representing real world things such as a customer or an
account. It allows things to be more clearly grouped.
• Most methods point to data fields within the objects, making it clean.
• An object oriented approach is good when working in large companies where
multiple programming teams working on the same code as they are relatively
independent.
• The same method names can be used across objects with no clash.
• A class is a template for creating objects.
• Members of a class are fields and methods.
• An object is an instance of a class. Each object gets its own copy of the members
• Members can be instance or static. Only instance members can be copied into each
ojet. Stati a’t e opied. If it does’t sa stati, it is istae.
• Class diagrams help to sketch and evaluate OO programs.
• An arrow between class diagrams indicates that one class uses another class. A *
indicates multiplicity (i.e. A customer has many accounts)
Design Rules
• Help to decide how to split up code.
#1. Encapsulation
• Fields are hidden behind methods.
• Fields are always private and methods go around the outside of the object and may
be public.
#2. Push it Right
• Push functionality as far right as possible.
#3. Spread Plans Across Classes
• By convention, when using the same method across classes, you should use the
same method name for the same goal.
find more resources at oneclass.com
find more resources at oneclass.com
Document Summary
Study 5: classes: procedural programming is where you work with various procedures. It is difficult to use procedural programming on a large scale, and this is where an object oriented approach is best: groups code into objects representing real world things such as a customer or an account. Each object gets its own copy of the members: members can be instance or static. Only instance members can be copied into each o(cid:271)je(cid:272)t. stati(cid:272) (cid:272)a(cid:374)"t (cid:271)e (cid:272)opied. If it does(cid:374)"t sa(cid:455) stati(cid:272), it is i(cid:374)sta(cid:374)(cid:272)e: class diagrams help to sketch and evaluate oo programs, an arrow between class diagrams indicates that one class uses another class. A * indicates multiplicity (i. e. a customer has many accounts) Design rules: help to decide how to split up code. Encapsulation: fields are hidden behind methods, fields are always private and methods go around the outside of the object and may be public. Push it right: push functionality as far right as possible.