1 / 22

CIT241

CIT241. Prerequisite Knowledge Variables Operators C++ Syntax Program Structure Classes Basic Structure of a class Concept of Data Hiding Concept of Inheritance Concept of Polymorphism. CIT241 Objectives. Study of data structures and algorithms Use of STL Containers Iterators

ailis
Download Presentation

CIT241

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CIT241 • Prerequisite Knowledge • Variables • Operators • C++ Syntax • Program Structure • Classes • Basic Structure of a class • Concept of Data Hiding • Concept of Inheritance • Concept of Polymorphism

  2. CIT241 Objectives • Study of data structures and algorithms • Use of STL • Containers • Iterators • Algorithms • Searching • Sorting • Other • Use of C++11 new instructions • Auto, Array<T,N>, lambda, intelligent pointers, tuples

  3. Why C++ • Where is it being used • Real-time systems • Embedded products • Building tools • OSs • Compilers • Tools for developers / designers • Games • Reasons • Speed • Closeness to machine architecture (Native) • See http://www.stroustrup.com/applications.html

  4. Programming Languages • Java • Write once, run anywhere (there’s a JVM) • Huge framework • Garbage collection • .NET – C# and VB • Write once, run anywhere (there’s Windows) • Huge framework • Separation of concerns – visual designers / developers • Garbage collection • C++ • Compilers for most machines • Differences – machine architecture, OS services • Stack and Heap • Automatic deallocation using smart pointers • Commercial libraries provide good amount of frameworks

  5. Software Design • Software Life Cycle • Analysis – the What • Design – the How • Implementation – the Code • Testing and debugging – the Quality

  6. Survey from CodeProject

  7. Design Methodologies • Structured design • Waterfall methodology • Data Flow Diagrams, Structure Charts, HIPO diagrams, Pseudo Code • Functional decomposition • Object-Oriented design • Iterative and Incremental design • UML – use cases, class diagrams, sequence charts, state diagrams, packages • Object decomposition

  8. Agile Methodologies • Do only what is necessary • Capture requirements at a high level • Develop small, incremental releases and iterate • Write tests before code • Refactor code • Pair programming

  9. Algorithms • More than one approach • Deals with trade-offs • Memory space • Processing time • Simplicity of code • Study of Data Structures and Algorithms • Containers • Functions • Searching and Sorting

  10. Big-O Notation • Efficiency of an algorithm • Interested in asymptotic behavior • Especially as it approaches infinity • Measure number of operations • How does number of operations grow as number of elements grow

  11. Growth Rates

  12. Searching • Linear search • Binary search • Cost of two methods • Frequency of adding new element • Frequency of searching for an element

  13. Classes and Objects • Class represents a type of object • Extensible programming language • Encapsulates state and behavior • Reusable • Classes used to model problem • Objects are the instances • Data members represent current state of a single object • Behavior is shared by all objects of a class

  14. Determining Classes • Problem Domain • Vision • Use cases or scenarios • Nouns as potential classes • CRC cards • Responsibility • Sequence diagrams • Actor interacting with Interface class(es) • Interface class interacting with domain classes

  15. Relationships between Classes • Has a – composition • Is a – inheritance • Uses – association • Relationships have multiplicity • 1 – 1 • 1 – Many • Many – Many • Many(s) in model most often held in container

  16. Class • Data members • Fields • Static Field • Member functions • Accessors and mutators • Standard C++ does not support properties • Implements get and set functions • Static member functions • Accessibility • Private • Protected • Public

  17. Class Methods • Constructors • Constructors with default parameters • Destructor • Public • Private • Built-in Operations • member access (.) or (->) for dynamic objects • assignment (=)

  18. Patterns • Model/View/Controller - Separation of concerns • Data part • Presentation part • Control part – handle requests / events • Data Persistence • Separate data from storing/retrieving of data

  19. Date Class • How is it going to be used? • Methods • Constructors • Destructor? • Set/Get functions • Calculation functions • Formatting functions

  20. Vectors • Vector is a dynamic array • Can grow or shrink as needed • Vector is part of STL, hence uses template vector<int> intvect; vector<Student> studentvect(24); • void push_back(const T& newelem); • T& operator[](size_type n); • const T& operator[](size_type n) const; • T& at(size_type n); • const T& at(size_typen) const;

  21. Accessing the elements • Regular for loop, range for loop • For loop for (intndx = 0; ndx < vint.size(); ++ndx) { cout << vint[ndx] << endl; } for (auto iter= vint.begin(); iter != vint.end(); ++iter) { cout << *it << endl; } • Range for loop for (intcurr : vint) { cout << curr<< endl; }

  22. Project 1 • Simple ToDoList Application Need to capture an activity that has a description and a planned completion date. Need to have the ability to add an increment to the date for an activity. The increment can be both negative and positive. We would also like to capture the difference between two date values. We need to record the actual completion date element for an activity as well as its planned completion date value.

More Related