Misc Flashcards
4 pillars of OOP
Abstraction
Encapsulation
Inheritance
Polymorphism
Abstraction
Avoid repeating code by abstracting concepts so same code can be used multiple times, use classes and variables to represent complex code simply
Encapsulation
Keep fields in class private and provide access through public methods (eg. getter and setter methods). Public variables bad if you want to use the same names in different class, and for large code base it’s good practice to keep things separate so you don’t need to know what every variable is called in order to make a new one
Inheritance
Can create classes (child classes) that inherit attributes of existing ones (parents). Avoids repeating code, can build from a very abstract class to add more specifics in a child class, but still keep the value of abstraction in the parent
Polymorphism
Method overriding - child class can override method from parent with its own version with same signature, and that child version will be used instead of the parent
Method overloading - can have two methods of the same name in one class, just with different signatures (take in different parameters)
Java Interface
Completely abstract class - groups related methods but does not implement them (interface contains only signatures, not bodies). Have to implement the interface within a class. Good for security (can hide certain details of an object), also makes multiple inheritance (inheritance from multiple parent classes) possible in Java.
Software development lifecycle
Planning
Analysis
Design
Development
Testing
Integration
Maintenance
Planning
Determine objectives and scope of project, set schedule, figure out what resources are needed
Analysis
Determine needs of users, evaluate alternatives/existing methods or prototypes, define requirements for end product (basically, define specifications for detailed idea of what project will involve)
Design
Design system and user interfaces, figure out what network will be used/requirements for the network, design structure of any necessary databases, and what programming languages to use
(Basically UX design and architecture of code)
Development
Actually write code to build the thing, using prior designs and specifications as guidelines
Testing
Test the code/system as a whole, make sure it does what’s intended and doesn’t introduce unforeseen problems
Integration
Integrate separate pieces of the project together and situate in working environment (basically putting together all the parts that individual teams might work on, should be usable by end users at end of this stage)
Maintenance
Fix bugs that come up (both from user reports and things left over from before launch)
End with idea that this is a cycle for a reason - every time features are added after the main launch they go through a version of this process again
Sudoku project
Used Java and processing (Java gui library) to build a sudoku editor.
Simple object oriented programming project, did it when I was just learning Java a while ago
I learn best by doing and figuring out new aspects of something as they come up - started with totally wrong idea and rebuilt with a better structure
Has a couple classes - cell, game set, and actual game
Pulls random games from a file of 1 million random ones (loads 100 at a time)