Software Development Technique - Topic 03
Upcoming SlideShare
Loading in...5

Software Development Technique - Topic 03



Software Development Technique - Topic 03

Software Development Technique - Topic 03



Total Views
Views on SlideShare
Embed Views



3 Embeds 365 363 1 1



Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Software Development Technique - Topic 03 Software Development Technique - Topic 03 Presentation Transcript

    • Scope of Topic 1. Primitive and complex data 2. Data and computer memory 3. Scaling 4. Choosing the right data type ER. PRADIP KHARBUJA
    • Variable A variable is a contianer for a specific kind of data. The value of variable can be changed through out the program. Pseudocode to create and set a variable data first_name as string first_name = "John" ER. PRADIP KHARBUJA
    • Data Representation • While writing pseudocode or program first, decide what information you are going to need to store. This is data representation. • Data representation is one of the most important things to get right when designing an algorithm. • A good data structure will make algorithm much easier to manipulate. • It is important to decide how your data is going to be structured. ER. PRADIP KHARBUJA
    • Data Types • It determines the type of data that can be stored in variable. 1. Whole Number  integer 2. Real Number  float or decimal values 3. String  collections of characters 4. Character  A data type which contains a single unicode character 5. Boolean  A data type which contains either true or false. It can hold nothing else. ER. PRADIP KHARBUJA
    • Types of Data Types  two kinds of data type in most modern programming languages. 1. Primitive data types are the building blocks that are used to build all other data types. • Whole numbers, real numbers, characters, boolean • Primitive data types are also known as value data types. 2. Complex data types are those made up of combinations of primitive data types. • Strings, Object, Array • Complex data types are also known as reference data types. ER. PRADIP KHARBUJA
    • Default Variable Values ◦ When we create a number in our pseudocode, the first thing we do in our desk-check is set its value to 0. ◦ This is its default value. ◦ It is a convention of our pseudocode ◦ It is not something necessary that all programming languages set default value to 0. ◦ Default Value for boolean is false ◦ Default Value for character is null or NA ◦ Complex data types have no default value, they start off as null values. ER. PRADIP KHARBUJA
    • Null Value  It is nothing.  You cannot use null value in calculations.  You cannot output null value.  If you attempt to perform any kind of operation on a null value, a computer program will usually crash.  The only thing you can do with null values is input data into them. ◦ Either via user input ◦ Or via explicitly setting the value with = eg. answer = “The answer is” ER. PRADIP KHARBUJA
    • Computer Memory ◦ Every piece of data that is used in an algorithm must be stored somewhere. It gets stored in the computer’s memory. ◦ There are real physical constraints that impact on how we design algorithms. We have finite amounts of computer memory. We have finite amounts of CPU cycles. ◦ For very small and simple algorithms, neither of these are very limiting. ER. PRADIP KHARBUJA
    • Data and Computer Memory • Pseudocode lets us ignore the implementation details that go along with an algorithm. • One of those implementation details is how much space is taken up by different kinds of data. • Datatype is a wrapper around some part of the computer’s memory that determines the memory occupied by the variable. • Because the data type is just a wrapper, different languages can handle data types differently. eg. Some languages handle a String as a list of characters. eg. C, C++ Some languages handle a String as a custom data type. eg. Java, C# ER. PRADIP KHARBUJA
    • Sizes of Data Types Type Java C++ Whole number 4 bytes 4 bytes Real number 8 bytes 4 bytes Boolean 1 byte 1 byte Character 2 bytes 1 byte String Number of letters + 2 bytes Number of letters + 1 byte ER. PRADIP KHARBUJA • The size of every data type is different for each programming language. • So why the size of data types vary?
    • Range of Data Types Type Java C++ Whole number -2,147,483,648 to 2,147,483,647 -2,147,483,648 to 2,147,483,647 Real number Boolean true / false true / false Character A character A character String A series of character A series of character ER. PRADIP KHARBUJA -2^31 = -2,147,483,648 2^31 – 1 = 2,147,483,647
    • Scaling ◦ Scaling is the degree to which an algorithm can work for larger sets of data. ◦ Many algorithms suffer from 'scaling issues' ◦ What works for ten items of data, may not work as well for a thousand ◦ The decisions we make about the data we store will have an impact on how useful the algorithm is for larger tasks. ◦ Choosing the wrong data at the start will impact on scaling. ER. PRADIP KHARBUJAS
    • Scaling Example ◦ A program needs to take age of a person ◦ A program needs to check whether a person is online or offline ◦ Now the status can idle, invisible, busy. ◦ A program finds the product of two numbers. ◦ A program finds the product of two numbers of 10 digits ◦ A program stores the result of factorial. ER. PRADIP KHARBUJA
    • Generate a desk - check ER. PRADIP KHARBUJA
    • Memory leak Memory leak occurs when a computer program incorrectly manages memory allocations A memory leak can diminish the performance of the computer by reducing the amount of available memory Memory leaks are a common error in programming, especially when using languages that have no built in automatic garbage collection, such as C and C++ Memory leaks are caused by memory being used up but never freed when the computer program is finished. By having columns that indicate how many variables we have in use, we can see if we have flaws in our logic that result in memory leaks. ER. PRADIP KHARBUJA
    • Choosing the Right Data Type ◦ Choosing the right data type is important, because it makes everything else easier. ◦ You need to consider: ◦ What kind of information you need to store ◦ What kind of manipulations you are going to do to the data. ◦ What kind of format will be used for output. ◦ How often you might need to change the representation. ER. PRADIP KHARBUJA
    • Choosing the Right Data Type - 2 ◦ What is the best data type for... A phone number? An address? The gender of a student? The age of a person? ER. PRADIP KHARBUJA
    • Choosing the Right Data Type - 3 ◦ It is often dependent on context. ◦ A phone number is usually best stored as a string. ◦ An address is also best stored as a string. ◦ A Boolean or a character might best represent gender. ◦ The age can be a whole or real number. ER. PRADIP KHARBUJA
    • Phone Number - 1 Why is a phone number best stored as a string? ◦ It says number right there in the name! ◦ It is to do with how the data gets manipulated and output. ◦ You hardly ever do arithmetic on a phone number. ◦ You often need to structure a phone number in chunks, such as 123-456- 7890. ◦ Phone numbers often have a leading 0. ◦ 0123-456-7890 ER. PRADIP KHARBUJA
    • Phone Number - 2 ◦ Strings are best for phone numbers, because on the whole, we do not treat phone numbers as numbers. ◦ They are unique codes that just happen to be made up of all numbers. ◦ However, there is always a trade-off. ◦ Easier to structure as a string. ◦ More difficult to arithmetically manipulate ◦ We choose the path of least resistance. ER. PRADIP KHARBUJA