ieg 3080 tutorial 1 wilson ip. outline lecture reviews: some basics of software engineering...
Post on 21-Dec-2015
215 views
TRANSCRIPT
Outline
Lecture reviews: Some basics of Software Engineering principle
Some basics of OOP How to use Visual Studio .NET 2005
Create a Project Console HelloWorld program Compile and Debugging tools
Lecture reviews:Software Engineering principle
Potential challenges for building a complex large scale software Difficult to debug
Unreliable software might be delivered. Users change the requirement
A change might propagate throughout whole system Managing large team
Inconsistencies in interpreting the requirement Difficult to merge the work done by independent indivi
duals Difficult to maintain
Maintaining the code from other teams/divisions/people who have been turnover
Possibly more…
Lecture reviews:Software Engineering principle
Solution Source or binary code reuse
adopted the well-written code (but not allowed in assignments and project) Interface and Design Pattern reuse
Make system flexible to change Facilitate future maintenance
Setup a effective way of communication Precise documentation
Visually model the software UML
Software development Methodologies WaterFall Rational Unified Process Extreme Programming
Regression tool NUnit
Lecture reviews:Software Engineering principle
Dealing with a complex System Divide and Conquer
Break a complex problem to simple problems Separation of Interface and Implementation
Promote loose coupling, modularity, encapsulation and abstraction
Object Oriented Programming Traditional programming such as C:
Sequence Condition – if, else if, else Repetition – loop Recursion Variables
Divide big program into subroutines for modular structure
OOP uses Objects for modular structure Object is (in programming):
A module that encapsulates some internal state variables with a group of methods that alone have direct access to those variables.
It can be used to model any real world/abstract objects
Object Oriented Programming
Example objects in real world TV
state - power, volume, contrast, brightness operation - turn on, turn off, vol_up, vol_down, …
to change the state
In modeling, pick out some properties from the real object to be modeled
Example, to model a reader Attribute : name, status, max # of books, # of book lent,
…. Action : lend, return, ….
Object Oriented Programming
This shows an object in programming
The internal attributes cannot be changed without carrying corresponding action. You cannot decrease the
number of books lent without returning the books
Actually, attributes will be internal state variables, actions are the methods .
Name
Status
max # of books
# of book lent
LendReturn
Object Oriented Programming
Class and Object Class – blueprint of an object, specify how t
he object will be built IF WE REALLY BUILD IT
Object – really build the product by following what is specified by the class
Instantiate an object = allocate memory for attributes, codes for the methods specified in the corresponding Class
Analog for the relationship Class – Mold for producing the Moon cake Objects – The Moon cakes produced by this
mold
Object Oriented Programming
Constructor Constructor is used to initialize the attributes
when the object is created Constructor is a function, its name is the same
as that of the class Constructor has no return value There can be more than one constructor in the
same class (By function overloading)
How to use Visual Studio .NET 2005Create a project Menu -> file -> new -> project Choose “Visual C#” Choose “console application” Give a project name, say “308” Choose the location, say “C:\” Then, everything will be within the directory “
C:\308”
How to use Visual Studio .NET 2005 Console HelloWorld program
Function “Main” is the entry pt of the whole program (same as the main() in C/C++)
“static” means that it can be called even no object is allocated, just like “Console.WriteLine”
You can try to simply write a line “Console.WriteLine(“Hello World”); in Main
Using System;Class HelloWorld{
public static void Main(){
Console.WriteLine(“Hello C# world”);}
}
How to use Visual Studio .NET 2005Compile and Debugging Tools Compile
Menu Build Build Solution After compile, execute without debugging
Menu Debug Start Without Debugging Execute with debugging
Menu Debug Start With Debugging Debugging functions:
Step-by-step execution Insert breakpoint
How to use Visual Studio .NET 2005 Compile and Debugging Tools Step-by-step execution:
choose Menu Debug “Step Into” continue to press Menu Debug
“Step Into” to run only the current line of code and go one step to next execution line.
The value of local variable with scope of execution line is shown in left bottom box
You can view a particular variable by select the variable right click “add watch”
If execution come to function call, it jump into the function
If execution come to function call, press Menu Debug “Step over” to skip jumping into a function
If execution inside a function block, press Menu Debug “Step out” to jump out one level from the function block.
How to use Visual Studio .NET 2005 Compile and Debugging Tools Menu Debug “Step over”
Menu Debug “Step Out”
How to use Visual Studio .NET 2005 Compile and Debugging Tools
Insert a breakpoint : Menu Toggle breakpoint The program will be paused when it hits the break point. You can assign break point at any line in the program.
Insert break point Menu Start with Debugging Program pause at thebreak points
How to use Visual Studio .NET 2005 Compile and Debugging Tools
You can break the program when some condition are fulfilled.
E.g. The break point below is activated only if at the execution that satisfy TestVal2 < 20