0
Upcoming SlideShare
×

# Software Development Technique - Topic 03

1,584

Published on

Software Development Technique - Topic 03

Published in: Education, Technology
1 Like
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total Views
1,584
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
103
0
Likes
1
Embeds 0
No embeds

No notes for slide

### Transcript of "Software Development Technique - Topic 03"

1. 1. Topic 3 : Data Representation Er. Pradip Kharbuja Er. Pradip Kharbuja
2. 2. Scope of Topic 1.Primitive and complex data 2.Data and computer memory 3.Scaling 4.Choosing the right data type Er. Pradip Kharbuja
3. 3. Variable A variable is a container 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
4. 4. 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
5. 5. 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 Er. Pradip Kharbuja
6. 6. Data Types 3.Character A data type which contains a single Unicode character 4.String collections of characters 5.Boolean A data type which contains either trueor false. It can hold nothing else. Er. Pradip Kharbuja
7. 7. 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. Er. Pradip Kharbuja
8. 8. Types of Data Types 2.Complex data typesare those made up of combinations of primitive data types. •Strings, Object, Array •Complex data types are also known as referencedata types. Er. Pradip Kharbuja
9. 9. 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 nullvalues. Er. Pradip Kharbuja
10. 10. Null It is nothing. You cannot use null in calculations You cannot output null. If you attempt to perform any kind of operation on a null, a computer program will usually crash. Er. Pradip Kharbuja
11. 11. 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. Er. Pradip Kharbuja
12. 12. Data and Computer Memory •Pseudocode lets us ignore the implementation detailsthat go along with an algorithm. •One of those implementation details is how much space is taken up by different kinds of data. •Data type is a wrapperaround some part of the computer’s memory that determines the memory occupied by the variable. Er. Pradip Kharbuja
13. 13. Data and Computer Memory (Contd.) •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
14. 14. Sizes of Data Types Type Java C++ Whole number 4 bytes 4bytes Real number 8 bytes 4 bytes Boolean 1 byte 1byte Character 2 bytes 1 byte String Numberof letters + 2 bytes Numberof 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?
15. 15. 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 seriesof character A seriesof character Er. Pradip Kharbuja -2^31 = -2,147,483,648 2^31 –1 = 2,147,483,647
16. 16. 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
17. 17. 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
18. 18. Memory leak Memory leakoccurs 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. Er. Pradip Kharbuja
19. 19. 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
20. 20. 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
21. 21. 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 or String might best represent gender. •The age can be a whole or real number. Er. Pradip Kharbuja
22. 22. Phone Number Why is a phone number best stored as a string? •It says numberright 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. eg. 0123-456-7890 Er. Pradip Kharbuja
23. 23. Any Questions? End of Topic -03 Er. Pradip Kharbuja
1. #### A particular slide catching your eye?

Clipping is a handy way to collect important slides you want to go back to later.