Transcripts
1. Object Orienting Programming, introduction: Welcome DOB. Degree of programming. A conceptual approach. My name is Tevis Boulware, and I'll be the instructor for this course what this course is all about. This course covers analyzing, designing and creating basic, object oriented programming with an emphasis on the concept, processes and program structure over the actual programming details. Programming is vitally important, However. Many introductory programming courses jump straight into programming without covering the fundamental concepts, the foundation of every object oriented programming. This course takes a concept first approach. One of things to notice is that concept and processes over program. It means that what we're gonna talk about applies to any programming language, whether it's C, sharp, Java or python or whatever your language of choice is, the concepts were all the same. The only thing that's different than is the implementation details of those concepts. What you will learn in this course, you learn how to design a basic, obvious going and programming using the unified modeling language. Don't be intimidated by this. It's a standard way that professional programmers Incheon and software engineers used to document the blueprint of their language. It's not. There's intimidating it. It seems to be you're gonna learn how to create a design that incorporates multiple objects and that allows message passing, passing between the motel objects. My experience is that introductory students have the hardest time working in programs with multiple objects because they have to take data from one and put send it to another and back and forth. That's usually the most complex things that introductory programmers have to learn, and so we're concentrate on them. Are you gonna learn how to take that design or which is your blueprint, and then translate that design into an optical on your program now one of things I really want to concentrate on. The concepts and processes covering this course do not depend on the programming language I'll be using. C. Sharp is the primary language used to demonstrate the techniques because I think it's one of the easiest languages learn and one of the easiest language to read. But other languages examples will be shown to illustrate the commonality between the different language. What you're gonna find in all the languages support the same general concepts. The only difference is then, is going to be the specific details of the language that implement those concepts. Now we want to make sure we understand what this course does not do as well. This course will not concentrate on the user interface. As soon as we start talking about user interfaces, graphical user designs and things like that you raised put a level of complexity in there that takes away from the object Korean concept. We're just going to concentrate on simple council based pros programs so he could concentrate on those fundamental concepts. And then user interfaces will be the subject of another course. We're not going to cover any detail programming language again. I'm gonna be using C Sharp is the example also social show some Java programs, some python programs. But there are plenty of tutorial programming sites available where you could learn how to work with the specific language. I'm not going to cover specifically which details in this course. We're not gonna do any complex programming algorithms, and we're not going to cover some of the more immediate intermediate or advanced topics such as composition. And here it is abstract classes. Those are gonna be subject. Subject another course. Do you want to understand the basics off? What are the basic concept of objects and how they communicate, how to build those programs. And once you have those down, then you could go into the more intermediate intermediate concepts. So what he can need for this course, you need to probably have some basic skills and working the computer programming language of the assumption here is that you have taken some sort of you have some sort of programming background. You know how to write simple programs again. You could use java. I'm going to demonstrate Java Python C sharp. I don't know every other language. So little is the ones I will concentrate on. You probably understand the basic probably programming control structures, such his decisions and loops. We're not going to create complex programs algorithms, but you need to be able to write some code with using if, if then else statement sloops and so on. You're gonna want a word processor text editor to do help us do some of the analysis and design and a programming ah drying program would be nice to have, but it's not necessarily mandatory. There's lots of free based, free, Web based tools out there you could use to draw, and you could always draw things with pen and paper because what we want to concentrate. It's important that you sort of draw out these diagrams because they're gonna become your blueprint. But it's the process we want to concentrate. Not necessarily. The drawing tools themselves a little bit about name again. My name is Thomas Boulware. Here's my education. I've got masters and computer engineering, mathematics, and I have from a bachelor's degree in electrical engineering, math, IQ, mathematics and general science. In my experience, I spent 15 years as a research and development in ear with US Air Force, primarily concentrating on software, engineering, research and development for the Depart Department offense, one of the best practices and so on and also spent 15 plus years commercial software, engineering. And also I have, ah, 30 years of part time university and college instructor experience. I've been teaching since I was a graduate student at University of Order. I'm gonna do in this course. Our first lesson is going to be talking about object Orient thinking. It's how we think it's human beings. What we just want to be able to do is be able to take our natural thought process of how we as human beings considered the world around us. And then how are we going to then apply those principles to object oriented programming? Then we're talking about the tools we're going to need to do object oriented programming. What, you're going to need this course. Then we're going to jump into how you describe a system. If you can't describe the system, you can't be able to build it. So we want to be able to describe the system and that then becomes the foundation for everything we do. From that point on, once we describe the system, we want to be able to see how the different commute components going to interact. That's a very important concept to think about before you start implementation. What we understand how the system but the structure of the system is how the components of going to interact. Then we need to basically write down, specify the specific algorithms were going to use, and again, we're not gonna be anything complex, but we're just going through the process. Okay, now we got right down the the algorithms that we're gonna process, and then those then become our blueprint for implementation or coating. So that's the process we were going to be following. So let's go ahead and get started and our first topic is going to be object. Korean thinking It's how we as human beings, think about the world.
2. Introduction to Software Development: welcome. The next lesson. An object programming software development. Lifecycle. What we want to talk about here is that in the following lesson, we're gonna go into analysis and design process and what I'd like to do a set the overall foundation for that process we're going through by looking at what a life cycle is in theory and some of the basic principles were going to use when we talk about the software development lifecycle, this is going to provide you with a foundation of the activities that we're gonna fall for . Development is an engineering process. Now what does that mean? It means it's a formal, standardized and repeatable process to create products. You start with identifying the need of assistance that you need to create. You research the problem, you identify possible solutions, you select the solution, you build a prototype ah, model. Evaluate that prototype and you find it. Implement design. So engineering is this formal, reputable process. Again, it's formal. That means it's that has a well established guidelines and standards. It's repeatable, same step for every project. It's gonna follow a life cycle which is basically syriza stages through which a system passes through its lifetime. The system development life cycle again is a logical flow of development activities that represent the orderly progression of activities from beginning to end. Now, one thing we have to remember is that even though we're going to be creating different things at the end, the process is the same. For example, funding a design and build a computer. You're gonna go phase one face to face three. Faith for you will define these phases based on your expertise and the expertise in the company that you working for. Now, if we gonna design and build a website, we're gonna follow the same phases. Notice down. Here is the repeatable activity. Say, Well, we're going to do the same things, same activities, but we're going to end up with different results. So that's what we mean by formal. In a repeatable and the software life cycle, we're going to go through an obstacle in the analysis. Design is a formal in logical process. Now, some of the basic principles any time you're going through analysis design is you want to think in terms of levels of abstraction. I know That's kind of Ah, hi life, highfalutin term. There But what we would think about is we want to think in the in the big picture and then delve into the details would necessarily want to then decompose our system, break larger systems in the components and those components into smaller component. We want to do stepwise refinement. Otherwise, we incrementally elaborate on the details of a system until you understand how the components work and rebuild smaller components and integrate them together to get it. Working system, for example, Piers in the system. I worked on a while back not, or made a pilot checklist this year automated pilot checklist and what you would call the highest level of abstraction. This is the 10,000 foot or big picture level we can't build on automated pilot checklist. Okay, you just don't know how to do it, But so what we have to do? He composed those components into sub components. So we're gonna break it graphics interface pointing device cad software checklist storage. And then where you would take each one of those and decompose it even further and you continue this decomposition process until you finally we get to a point says yes, I know how to build that there's once we built all the sub components, we then integrate them together to get our working system every systems development process I've ever worked on its followed this approach. And this is the approach we're gonna take when we do our object or an analysis designing its course now software development. And if you look at any of the textbooks, basically is gonna boil down into four basic processes problem specifications, which is going to describe the problem. We have to do requirements, analysis where we're going to take the problems specifications and define what the system must do. We're gonna take the requirements and we're going to create a design on that based on the requirements that's going to define how the system is going to do it. And then this becomes our blueprint for implementation notice here by the picture, you could always go back. One of the issues I see with the beginning engineers is that they're always afraid to go back. For example, they go design, go to design, then they go to implementation. And then again, the stepwise or fireman process sort of means that every time you uncover one detail and the closer you get the implementation, the more details are going to come up and you may come up with a design specifications or new requirement. And then when that happens, you should go back. The requirements that go through the design process is again, so don't be afraid to go back. You're never going to get it right the first time. The other thing is we won't remember specifications on the baseline for each face. For example, if I want to do design, I have to have requirements. If I'm going to do requirements, I have to have the problem specifications written down for you. And I really can't do implementation until have the design blueprint and then testing encompass all phases of the process. Now, this is not always just testing me. And we're executing a program. You can do peer reviews. You could do paper inspections to make sure that the artifacts is you're creating for high quality. And the purpose here is you have to build quality in that rushed through problem specifications, analysis, design, and get the implementation with the attitude or the thought that okay, I'm just gonna test quality and I'm gonna put it out there, see what is going to work, then they're going to test it. You can't really do that at each phase. You have to make sure that what you're passing to the next phase is correct. For example, few you can create a good requirement based on a bad specifications. For example, I want to build. My wife tells me we want to build a four bedroom house. However, when I go describe the problem, I say three bedroom house. Then I go to the requirements and passed Build a three bedroom house into the requirements analysis phase. Then I could do, ah, perfectly acceptable job of requirements, analysis and then design and implementation. But my specifications was incorrect, so I may build the best three bedroom house that's ever been built. However, it's not gonna be a quality application or equality house, because I was supposed to specify a four bedroom house so you can have errors propagate down at each one of these phases, which means you have to make sure that it at every phase before you move to the next one that the input to the next phase were correct. So one of the things you want to keep in mind. Software development, life cycles and logical, orderly progression of development activities. But it starts with the initial need determination through disposal. You're going to go through a problem specifications, requirements, analysis, design, implementation and testing. And then we're gonna go through this process, make sure we use the levels of abstraction, decomposes system and then stepwise refinement. Which again means that every time we go forward with the level of and identified a level of detail, more like more details going to come up way, find our understanding, the problem in this stuff. Why stepwise manner? Now this is Ah again, the presentation is just to give you sort of an overview of what we're going to dio when we talk about object or an analysis and design in the following lessons, you're going to see how these these theoretical concepts that apply directly to the specific engineering process
3. Object Oriented Thinking: another object. So we understand the basic concept of I was going program because this is the way we look at things in the real world. So basically in object or in thinking, you think about classifications. Otherwise, we're going to classify thing. For example, we have a classification of a television set. Okay, we have a classification of cars, classification of house, each one of those, as we've been billed, each one of this. We have objects in, or just specific instances or physical manifestation of those. So we have a classification of TV and there's hundreds of millions of TV optics in the world. We have a classification of cars and there's 100 millions of cars in the world their own. But they're old class buys bar we basically. Then I have, ah, classification of a house for hope, and then we have hundreds of different poem objects up. So basically what we want to think about is is a class is a blueprint for a physical thing . We then use that blueprint to create instance of the class. So, for example, if we have ah going to create a program that keeps track of your movie collection you're gonna then create a single class call, it moved, and that's then going to be. There's a blueprint for every other movie object you grade in your program. There you're gonna create or in stand shaped movie objects, one for each of the movies in your collection. So basically, when we talk about class for classifications, we're setting up a blueprint. A blueprint isn't not a thing. It's this basically the direction we're going to use the building, like a blueprint for a house is not a health. A house is not a house that that we've taken out blueprint and we translated to a physical . And that's what we gonna do in our object or improve. We're gonna identify these classes, we're gonna create blueprints. And then basically, once we've done that, we're gonna then and stand cheek or create objects of those so and again. If we look at analogy of home, Home theater system is a system of object where each object encapsulates a specific behaviour. Okay, it hides the complex processing details from the external users or entities, and it provides a simple public interface. What does that mean? I look at the DVD player then. Okay, what does that mean? And encapsulates a specific behaviour. It only plays DVD. Okay, it plays a reads a DVD through a laser. And since the audio out of since video out, it doesn't do anything. The DVD Dip player doesn't have any tweeters for resented the plate playing the music those air encapsulated within the speaker. Television, basically then is going to tank video signals and then display them. Receiver then basically has a specific function where it's going to wrap the signals, amplify the city and what's it meet until those hides those complex processing details? Well, for example, if we look at the internal workings of the DVD player, you've got blazers. You've got spinning motors, you've got three right arms, things like that. But us is users of the DVD player. We don't see them there. We don't interactive. When we just interact with a simple public interface, we have placed stops now rewind church and so on. I wouldn't play with the receiver. We play with the volume buttons and so details of those air hidden from us, and we only interact with those systems do of that basically well to find public interface . That's the basic, uh, concept behind encapsulation and data height, though each individual component is going to then encapsulate the behavior. And then we're gonna hide the details of processing from external ease. So encapsulation, which is the most fundamental concept of object drawing program each component contained features and functions that logical related to service the components provide. This simple concept is the fundamental characteristic, probably story analysis, and it's called encapsulation. They were going to use that same concept of encapsulation in the object or in program. What we're gonna do is we're going to in our analysis and design process, we're going to combine all the activites in the operations necessary to provide a service in a single component and what that means dislike In our stereo example, several classes are going to be required to complete the complete service I for free go back home theater system. We need a TV, we need speakers, we need to receiver and so on. So we're gonna have to combine those. And so each one of those smaller classes and provides a portion of the overall first. That's what encapsulation meat data hiding, on the other hand, is that we're going to take that those details, those complex details, and we're gonna hide them from the other units for the other entities in our application, for example, the disc player is a very complex component made up of hundreds of internal sub circuits. Have performed the task reading, reading, however issues. We don't see that we don't We don't understand what's going on within the laser and the motors and things like that. Okay, there's very easy plug ins. That's the interaction. If we wanted, then plug things into the player. That's usually just these days. That's just one plug in my cable. There's a few but weak used to control the operation. Stop, play, Rewind, Okay. And all the complex processing data hiding that is required to produce music or the sound is actually kept hidden from outside components. This is what they call data and information hiding, and it protects the integrity of the component because just think what would happen if we can get into the internal circuits of the display? Er, how were dropping that sat up very quickly. Now, one thing I want to point out is that encapsulation data hiding or two different concept of the analogy are used here. I got a coke machine up here, right. All right. A vending machine in this case here, in this example Here, it encapsulates all the items. All the Cokes I cook I have in there. But if the doors open, it's not head. Okay, that those those items are hidden. Anybody can go in and just get a coke just by, uh, reach in and grab. So we've encapsulated the coat, but we haven't hidden the Cokes. Anybody give now when we closed the door, okay? Not only read, encapsulated the Cokes, we've hidden the code. And the only way to get a Coke ASU, that public interface bites of submitting money and pushing one of but so as you go forward , keep in mind encapsulation the data hiding. They're two different things. Now, if you do research on the Internet, you're going to see some people think that encapsulation data hiding in the same thing. I prefer to that you, uh, that you think about this two different things because we get in the programming aspect of you, going to see how we're gonna be able to We can encapsulate things without actually hiding and in a good solid of the well formed object. Current programming you wanted not only encapsulate things, you also want to hide it. Otherwise, we don't want a Coke machine with open doors, lunar coat between with that that hides the details. And you have to get a Coke that well defined public interface. All right, now, this is actually the hardest part of object during programming by experience with teaching interest. Because that's message passing. If you think about it. If he ever put together home theater system, what do you have to do? You go home, you go down to your local electronics store or whatever, and you get your get all your components, you bring him home, you take him out of boxing, put him out there. It doesn't work. That means you get because you gotta interconnect. And the hardest part of putting together home stereo system is connected all the wires because you got to make sure that all the wires in the correct direction an output of one because then put another. If you plugged into the wrong poor, that's not gonna work. Things have to then be done with that message passing with that communication has has to be ah, well defined, well established. And it's actually the hardest part. Okay, so, for example, of those components must work together. Produced music. Dis player has to read the desk passes the signal to the receiver receiver than passes signals the speaker so we can hear the music. All right, So, basically, in an object reprogramming the components must pass messages between themselves and a well defined sequence in order to produce what every means. According audio, The same is true of our ob Victorian design. Each object is gonna provide some type of specific service, and there has been passive that information that messages to the other object in the system in order produced by my experience. It's this message passing and introductory students have the hardest time. What you're gonna find is you gonna I believe you're gonna find it's going to be fairly easy for you to be able to create objects and classes and things like that, but putting them together so they pass information and that well defined order if where it becomes difficult and we're gonna practice a lot of that between down into the course. And if you take the intermediate course following that, you continue the practice right now. So in that communicates remember of the to get the music, you must connect wires between the port and objects interact with each other by passing bill messages and that well defined sequence using only the public interface. And they have to be connected. Correct. And it's that this establishing that set of messages that is the hardest part. I have found students half when first being introduced, object on your program, right? So again, one of things were not going to cover in this class, and I want to make sure this is true. Those in the basic concept encapsulation and data hiding. And in this course that four we're going to cover, we're going to show you how to basically analyze it. Otherwise, where the components, the object classes not just you need build it and then basically how they then are going to communicate with each other. Those are basic building blocks of an object Korean program. But again, how do you we gonna, uh, eat an elephant one bite of the time? Because object oriented programming is a massive field, so we're going to start with. This is basic. Okay, building those classes how those office communicate Because once you've done that this since this the hardest part of it, then the more immediate concept of composition, inheritance, polymorphism, abstract classes, interfaces, then become much easier. This will be done in an intermediate court, but again, how do you buy a eat an elephant? One bite at a time, But let's start with the basic first and then after you've done intermediate, there's some more advanced concepts graphical user interfaces, designed patterns, architecture on working with databases. Files will be covered this love. So before you go into the intermediate, we want to make sure we could walk before we run by building simple, object oriented programming, identifying what object we need designing them. So what what's the data to those objects need of the operations they need before and how those different objects communicate? If you understand that, then we're gonna be able to be able to move into the intermediate course of some of the more advanced topics very
4. The Tools of the Trade: we also do optical analysis. Nine, We need some tools and what we're going to do in this short lesson is described the tools that you're going to need. You not only would need these for this course, but if you're going to do any programming outside analysis designed, you're gonna want to use these tools, become proficient with him and one of things you want remembers. Because any software development project is an engineering process, just like any formal, structured, repeatable process like building building any type of building a bridge, it's a formal, structured process. And with any engineering process, they always gonna have a set of tools of the trade. For this course. The tools we're gonna need is you could need a word processor. We're gonna just drawing program. But again, as I mentioned before, pen and paper is just fine again. We want you go worry about the process, concern yourself with the process, not necessarily tool, and then we're going to need an object going in programming environment on. But if you already had a programming done program, you probably haven't environment would work for the language of choice. Um, again, any drying program you'd like to use. Ah, this fine pen and paper find again. The purpose here is to go through the process. Not necessarily tool. If you do a search on free UML modelling tools, you're going to get several hits. The when I like to use my free free tool is draw dot io. And if you go to the draw audio I o site, you can see you be able to save diagrams. And, for example, just click the one Dr Puffed Rice Create a new diagram on my connection. Go through the diagram. But you notice down here all sorts of different types of tools UML diagram and then we can create it. Basically use the root folder. And we've noticed down here we get our basic UML diagrams and we could go ahead and expand on these well not free UML video is actually a very good deal. Melt modelling tool. It's not. It's not truly professional grade, but it's a pretty good for a quick and dirty drawings. And I will be using visual for all my demonstration for programming tools. Again, there's many amount they're dependent on the language you're going to use. You could use idle. If you're going to use a python, you could also create up idle pro Gore Python programs and visual studio as well. If you're going to use Java, you could net beans or eclipse. There's tons of mount there and again. My troll, Detroit's for this course is gonna be visual studio download, Visual Studio 2019 community. And if you go to the download site, your seethe of the farm and what you're gonna want to choose its don't choose to free trial with the Enterprise professional that you're only going to get those those air intended for large teams. Um, the only gonna get those for 30 90 days but you're gonna want to do is go to the free download community, download and download the and those down there it's going to download, and then once it starts download, save the file, then go in and execute. This could be a fairly large download. I'm not necessarily going to go through the whole process, but just started and then followed the fall of the installations instructions and your do just fine. It's relatively straightforward process, uh, down here. No sound here. Here is an article. And if you do a Web search, John installing Visual Studio 2019 community or find many videos as well, there is one thing I will talk about is and how you're going to actually want to configure it once it's installed. You want to make sure you have the correct opponents videos, visual studio downloads and begins the installation. Whether you're going to eventually get taken to this screen. Now, the directions and some of the other article do you gonna see, um, if you want to do C Sharp program and click this quick that make sure it's selected. Um, I found that even though the common direction say you just need thes, I have found it's gonna be helpful if you select that dot net core 2.2 development tools and also with the newer programs. I've had the 4.7 tools as well. I always sounded. Those were helpful to do that, provide more flexibility in the other one. If you go down and select Python, if you want to buy thumb programming, just conflict fault. Go and click modify and it will continue the operation. And then once that's done, you should be able to start open of visual studio and start
5. Creating a System Description: welcome to the next lesson. An optical reprogramming creating the system description. In my experience, creating the system description is one of the more unpopular activities that developers do so much, so often times the activities just skipped completely or if it is attempted a lot of times it's not. A lot of time has been on that, said his introductory developers. It's important to give you a place to start the analysis design process that I found that created the system description is the best place to begin. Hopefully, after this lesson, you will agree and use this process when you create your own programs. The goal of analysis and design is to understand the classes and objects you need to create your program classic. And you need to understand the class and object attributes and operations, the relationships between the classes and objects and the data and the messages that need to pass between the different classes of objects. But very important to know when you first start out, you don't know the details of all these what you want to make sure that you under do if you want to understand what you need to do without worrying about how you're going to do it. That's a big distinction between what? How, how is when you talk about one of the very detailed specifics that you need to accomplish what is exactly what you're going to do when we get into the design and the program process , You figure out exactly how you're supposed to do it. As you do the analysis and design try to think is high levels possible and avoid programming details during analysis and particularly, and also when you get into the design, you're gonna have plenty of time to think about the details. But here again, you want to think about what you're trying to do and not how you're supposed to do it. So before you ever start programming, if you can't write a detailed description of what do you want your system to dio, then you're not going to understand the system well enough to actually proceed. You want to be able to work on that system description until you insure yourself, and if you have any other people you're working with, agree on what the system is supposed to do now. This may not be all exciting, but it's extremely important, and one way or the other, you're going to do it. You either have to do it is a separate step or do it while you're trying to program. It's much easier to do it as a separate step to have avoid that hair on fire type of programming environment. What exactly is a system description? A System description is a text based explanation of the what the program is intended to do . Written in terms of the custom, the system description identifies a high level requirement, starting with a general statement of what the program is supposed to do. And then through refinement and in aeration, lower and lower levels of requirements are captured and document. I will not read the system description to you, and I said yet suggests that you posit video and read the description. We live in parts of description to be able to identify the objects and operations and the data for those objects in the next couple slides. So what do we need to identify as we go through the system description? One of things we want to remember a class is a name collection of members that whole dated methods that operate on the data fields and methods and the class or called class members fields being the attributes. OK, so when you hear the term class members, it could be anything that's contained in the classes. He do more reading, you hear that term is quite a bit. Some of those fields are the attributes and that variables those hold the data for the class methods and functions or the operations that provide the processing on the class attributes constructors, which we mentioned will. But earlier these air specialized methods at set up or construct the initial state of the object, we're gonna create getters getters, air specialized method that access to class data members and then centers are specialized methods that modify the class data Members were gonna illustrate how we capture each one of these and then eventually show you how you're going to implement. As I mentioned, the system description is basically the foundation for everything that we do. If we've done a good job with the system description, we're going to be able to identify all our objects and their class members. Okay, so we're going to use that system krypton to be able to extract those objects. All right, Now, I know you didn't think you come into an English class, but what we're going to find is that if we look at an object and object is basically gonna be what we a noun from the system description, for example, actors, things, organizational units, places, structures, notice Those were all noun type those announce and we're going to be able to Then take those, take that system description, identify the noun, and we're going to underline those now. Once we underline those downs what we've done, we basically created our list of potential classes and objects. So then now it's always we're gonna have some sort of verb or associate with those verbs in that are associated with those each individual. Now, we're gonna become the operations of those of the objects Every now and every now and and burb that goes along with it is gonna have a subject of those. Now we're gonna bulldoze, and that's gonna be the data that we're gonna that each one of those objects is going to contain. So let's parts the system description and see exactly how that how that looks. So when we start with the system description, it could be long. This is a fairly short one. I've seen these that have taken probably several years to create, and they will be 2030 pages long you can't handle without posing. What you want to do is you want to break it up, imparts it sentence by sentence. But in this case here, we're going to start with the top. And what we're gonna do is we're gonna document with what it's called a CRC these air, that class responsibility, collaboration card. And this is just a way for us to a tool for us to parse out the objects in their in their other class members. So we're going to start it. We parse it, meaning we're gonna break it up and we're going line by line. We say small start. A company developer needs to create an employee, but pay program Now calculate the pay with employees, though, in that first statement, we get our 1st 2 classes, we have a program and we have an employee. And so what we're gonna do is we're going to put those into this table, and we're going to use this table day eventually create the class diagram. For example, in this case, here we have a main employees notice down here. Sort of name I renamed it from pay program is what you're gonna find is every program is gonna have a class where it's going to be the starting point. The entry point of the application, my style and you're gonna see different styles is to use the term main and then basically the name of the program. This is where the entry point of the application, which demonstrated. But later on, you don't want to be able to describe what that class is supposed to be. What's the responsibility? Okay. For example, employees class, this is gonna be the business object that holds employee information and process is the pay . Do you want to be able to identify this? Okay, so we've identified in this case here our 1st 2 potential classes. Okay, so now we're going to go. We've done the first step. Now we're gonna break out the second part, okay? And we're gonna look for the first version of program. The company wants the payroll clerk to input. Okay, so we have a and a verb. Okay. And then we keep going down. And the employee's gross pay will then be calculated but another burb and then display. So now we then have to associate thes We have to associate thes verbs which are going to turn into our operations with the respective or the correct with the correct object. We look it again, we break that down again. We don't look at there's a whole we break it down. Statement by statement, we would. The company wants the payroll clerk to input. Okay, so that case here, we're going to put that and I'm gonna call this Get pay information. No, it's down there. I just didn't use the term input. I put a more descriptive name on it and then we have one down here display the main programmes also going to display. So I associate that with the main program nose down here, there's to sort of overhead functions that aren't included. They're basically I had to drive from the analysis is one it's going to be the main program is going to exist in that class. And then every program that I create is gonna have an exit program method that basically going to clean things up for the program, you know? So we have a main get display, and next, pretty much all the examples we're going to use our main program is gonna follow this This same structure. All right, then we have the employees. Growth pay will be calculated. So again, I say calculate gross pay notice. I distance, they calculate by very specific say, calculated gross pay. And again the program will display. And again, we're associating the display with the main program. This is a business units. It's not going to do any actual displaying toothy user. We're gonna let the main program handle that. And those are all basically these things here basically then all associated with the employee objects. We have employees name hourly pay, hourly work notice down here. I did not put a gross payment method. I just have a calculate gross pay. And what we're being going to then dio is where every time we want to the display, we're gonna calculated in real time also notice down here we don't let not list togethers and centers for the attributes show a little bit later on. It's always gonna be assumed that they're created if you create getters and centers for all these activities, When you have a long list of attributes here, your diagrams are going to get very complex. And then we have a, uh, this method here, get pay information. Now, this is not listed in the description, but what you have to do is sort of use your experience as you get a Z go forward that what we're gonna find is every time we create a non object for that example, this case employees were always going to have to wait and have a way to get information out of that object. But in this case here, I'm gonna call it, get pay information again. It's not listed, but we basically derived this from the requirements, knowing that where eventually would collect this data. We have this simple academic program. I have a program here that's going to draw the circle on screen. You noticed the same have the same design pattern structures are example Main circle and we have a circle class and all we're going to do in this program to draw the circle on the screen. Simple academic program. However, if I wanted to create a more real world program. I want to drop more into circles. I want to be able to drop program any shape you notice down here, the structure of each one of these individual items, relationships between the different classes. It's pretty much everything that we've covered. There's some details we have to worry about. But the complexity of this program is not because of the individual classes. It's the complexity arises because of the overall complex is the sheer number two classes that that have to go into the program, and the collaborations Simple becomes complex just by size alone. Now, one last note Creating the meaningful system description is hard work. So much so many developers don't even try. What you want to do is we want to make sure we get the ugly avenue away first because it's a communication intensive activity. There's a lot of refinement back and forth pork. Now, the thing about this is you're gonna do it now. Are you gonna do it later? As I mentioned, if you don't do this system descriptions the separate step making sure you understand what you're gonna do before you start designed before you start coating, you're then going to do it. If why you do design over near Cody, you're gonna do it one way or the other, and I'll experience shows and all the research shows for every hour you spend working on the system description and the making. Sure it's getting correct. It's gonna return it itself tenfold in the least longer. You've got to get that ugly out of the way. Sooner or later, you either do it now a separate step where you're gonna be doing this. Why you're actually programming makes it much more different. So the next step we're gonna learn, actually, how to take that CRC diagram and actually, how to create the UML a class diagram.
6. Some Fine Points: Hello. Welcome to the next lesson of object oriented programming. Fine points there. A couple five points we want to discuss before we go into the details of creating Ruml class diagrams. These are also very close to implementation details, which will try to avoid doing analysis and design. But it's a good idea to start considering these details wouldn't doing analysis the concept we're going to discuss and in this Lessner constructors instance, members and shared and static and we will cover the implementation details when we start programming later on. One thing we want to make sure we understand as we go forward is the difference between a class and an object. We've been using the example of building the house. A blueprint for a house is not a physical thing. It's on paper. It's basically thought stuff. It's basically how the house is supposed to be built. It's basically how the contractors in going toe follies two directions to construct a house . We use those blueprints to construct 1/2 and the house is a physical thing, and we can use the same set of blueprints to create many houses as we want from those blueprints we can create 100 houses, and if we use the same blueprints, they're gonna be 100 identical houses. Now we use that same idea, an object. Korean programming classes are not physical thing. We're gonna create our classes, which are dinner gonna be basically blueprint for the objects. We're going to use those classes as a blueprint to construct objects. Those objects will be created in memory and these objects in our physical things that we could then work with the question becomes, How then do we construct a object in memory based on the class definition? So let's look at the mechanism to create objects, and that's with constructors. We look in the dictionary for the definition of constructed is to build a re direct. So when you created an instance of an object, otherwise instant is a physical thing of a class. We need to construct the object. And those are the program execution steps necessary to set aside member and initialize the optic variable. Now, again, I'm gonna emphasize, keep in mind, an object is a physical thing in memory that is constructed using the class definition as a blueprint for the construction. With that definition, mind we're gonna define a constructive freed's class and keep in mind it is a specialized method that has the same name is a class no return type, and the constructor then must be invoked each time a new object of the classes created. So this is a class we have employees class with its Ah, Constance. It's very both and its data members. And then we're always gonna have a specialized method called employee noticed. That constructor method is always the same. Name is a class notice. There's no return type noticed. The constructor method is always the same name as the class, and there's never gonna be any return type. And when we want to create a new object, we have to invoke the constructor. And we do that. We using the new keyword new employees, new employees who employ what this statement saying is basically then gonna invoke the code inside the constructor to physically create those object memory. Once you've created those objects in memory, we could then immediate manipulate them individually. Now we want to look at that another term that you're going to hear quite a bit and that's an instant took a dictionary definition and instances, an example or single of occurrence of something. In short, if you have an instance of something, you have one specific 10 tangible thing. Both. For example, you can have several apples, each being a specific instance oven apple. Each of these is unique, separate object that can be handled independently of each other. Now we're going to use the same concept in our pro but then associated with each instance of the object. So if I create three memory objects of employees by one employees to employees three. These are all instances of of the employees class. Each one of those has her own copy of the variables employee name, pay rate and hours worked. This in case here, Bill 45 hours worked again. Each one of these instance members is recreated each time an object is made. So we have an instance of an object, and these in our called instance members why we're not gonna talk about right now, but we're going to also find out that methods can be instance members as well. But right now we're just gonna worry about the variable. The one thing you wanna always keep in mind when we put an object of memory that is an instance of the class. So if reached new object recreate, we're gonna have instance members that they re created for each object. So what you want remember each objects instance. Members is then recreated for each instance of the object. If three employees objects were created, then there will be three copies of employees. Name pair. Eight hours worked with each being encapsulated and then closing object. If we then created 100 employees objects, then there would be 100 copies of each instance member of the class. Now that there's a distinction between what they called static, where you often hear the term shared members, static or shared, members are members that are part of the class but not specific to any object of the class . But for example, we have our employees object here, and the default name minimum rate, maximum rate minimum hours maximum aren't specific to any specific object, so we don't want to have to recreate those for every object. So what we're going to do is we're gonna define those is static or shared members, and what happens is those variables in this case, constant are then associated with an employee class. There's only gonna be ever one copy of the static members, and each one of the individual objects, if they need access to those, are going to share those values now. Don't worry too much about the details and how Oregon implement constructors and statics methods. Those details will be covered, and we begin programming. However, you want to be become familiar with these concepts, it's they and they both will come up in analysis and design. The more exposure to get to these concepts, the easier the implementation is going to be. Now that we've been introduced to the concept of constructors, instance of objects, instant members and static members, we could then proceed with our in the office and sign.
7. Creating the Program Structure: welcomed optical reprogramming. The next lesson in this lesson we're going to discuss how you create your mail class diagram from the CRC card that you created in the earlier lesson. As you probably have discovered, creating the system description and the class responsibility collaborations Guards can be difficult. The comments I get from both introductory students as well as many seasoned developers, is that the initial analysis and capture the system requirements heart because it's so fuzzy that is, you were the customer, and I know what you want. Each time you think you have the requirements nailed down, someone changes their mind. However slowly and step by step, you eventually create a version of the high level requirements as sufficient detail to proceed. I think what you're fine, that once you have a high level requirements captured, the follow on processes are far less fuzzy and much more concrete and easier to understand . As you'll find as seasoned developers or tell you the more concrete the activity, the easier it is to grasp, and the more fun it is to carry out in this lesson, we're going to translate to CRC cards into a unified modeling language class diagram, which then takes us one more step towards the concrete to create the design elements. We need to take us to program a lot of heavy lifting. We've identified our classes. We've identified the operations, the attributes of the class. We put it in the CRC card format. I use a table type format and that you can do this anyway you like. But what we do is we've identified the responsibilities, operations and attributes and collaborators between the different objects. So how do we then take this information that we have here and translated into the UML class diagram trying to use video? All the tools I've ever used do the basically the same thing sort of the same operational steps. So I'm gonna first thing. I'm gonna go to start a new file and notice down here when I go into visit you. My favorites are the ones I used previously are listed up. But you may not see that a fuse and video overuse dry. Oh, if you're just doing this Sunday on a piece in the paper, are you gonna you know, it's basically the same steps, so I'm gonna go to software and nose down here and I have a human UML class diagrams. I select that in this case here, I want us unit and then notice Over here on the left, I get all the different shapes of that we could use new middle class time. We're only going to use a couple, But 1st 1 says, let's go ahead and take. We need a class. This two classes, one main employees they have unemployed. So it's built each one individually. So we're gonna do the main employees. So I'm gonna take a class. I'm gonna drag it over. You know it. Zoom in on that a little bit. So I see a little bit easier. Okay? And then we get the class name again here. I'm just going to I'm just using the template in the CRC cards, as as a template here at the blueprint to create the class diagrams. So it says, Okay, I'm gonna create something called main employees. So I type in main employees and again noticed. Don't. Here. I don't put any spaces in a UML diagram. This top block up here is reserved for the attributes, and the minus means that it's gonna be private B plus and then almost all attributes, except for constants, are almost always gonna be minor. So I go in and I said, Okay, what do I need? I don't have any actual act tributes in the main class I've listed. Okay? And so But now I do need to put in the operations. So if I don't have any attributes, you could believe it there. Or you could just cut it out. And so there's no attributes that's perfectly acceptable. Now, in this case here, I'm going to have a main function. It's on there, type in main function, and then I'm gonna type of Maine. Now, in this case here, we don't as we gonna talk a little bit later on, this is going to be a shared function or a static function. So I want to underline it. So underlined that function. No, I want to add another function. I could just hit return in this case. Or I could insert a member after and again, I'm gonna have a another get pay information, another method. And again, this also is gonna be a shared method, which we talk about in the next lesson. The incident of the member After display pay information. Insert another member after plus, and it's gonna be exit excellent. Rename this Terminate program the main employees class. I have the main employees class. I have a main function, which is going to be a static member. I designated that it is a function just for readability but in the parentheses there to show that it's not accepting any information. And I should probably say it's always going to be a void function. Otherwise, I'm not going to return any values again. This is maybe close to a design decision that you make, but if you get identified now, it doesn't hurt to do it. Have we get pay information method that's gonna be void, not accepting value? The underlying means. It's static display pay information and also terminate pro program. Now I'm going to say Go backs. OK, now let's create employees class, so I bring another class into the drawing here. It's a dis name it exactly Now, Remember earlier I said, As you go through step by step, we're finding the information. We're finding the details. You're going to be doing that as you as you make these translations from 11 element to the next. In this case, here we have what we have to do, what we want to dio and then going down here. We start creating new Mel diagram. We could refine our information. We could add more and more details, for example, appear, I decided he's going to be in the mean employees. I decided these work and they're not going to accept any arguments right now. I'm gonna do the same thing in employee class in this case here. I'm going to put in the attributes first because they go into the top block over here and I'm actually going to give the some data types. So I'm going to say all the attributes, mostly in the programs I create are all going to be private, not create getters and centres later on. Don't this case here on you do employees name, and then here I'm gonna put a colon and I'm gonna put the data type. This is when I have to start thinking about it. I'm getting closer and closer to implementation, so you have to start thinking about there. Said, uh, this type of information. Now again, the stepwise refinement processes Every time we take a step forward, it drive more detail. So employees name might get spelling we name correctly. And then I put the coal and this is gonna be a string value and then add another half boards and again, it's gonna be a private. So I put the minus in front, and I'm gonna changed in a from hourly pay rate to pay rate. And again, that's gonna be a double value because we know from the requirements that this is gonna be some value, some real number. So it has to be a double value. I do insert afterwards again, it's gonna next one is gonna be hours worked. I just call it hours worked. An hour's work can also be a real number. So this is gonna be a double data value. So now it's OK, my attributes to find Let's go ahead and create the methods. In this case here, I've got a method called cock Wake Gross pay. And again, I may have to think about this a little bit before Internet. What is calculate gross pay how visibility, What data is going to then accept and so on is by go through the attic now analysis and again, I may refine this later on. It's when I start creating the actual Sudoku process. A For what? We will be doing a couple steps and said, Well, this is gonna be private. My initial thought it's gonna be calculate gross pain. I name it. I'm not gonna accept any values because I'm gonna be able to use to pay rate Now we've worked in the class. I don't have toe go get any values. I don't know if the past, any values in and this is gonna be avoid. Nor actually this is going to return a double value because it's actually the growth pay. And again, this is just design. And as you go forward each step, you may change its. That's fine again. We may not get this 100% crack this first time through, but we're getting things more more clarified as they go for it could always change it later . Nothing's written in stone at this point. So I do another one. I go to get pay information so pay informations could be public because what I need to do in this one is I need Teoh collect all this information employees name hours worked in the gross pay, and I need to pass it back to the main function for passed back to the main function for display. But this isn't the public, so I have to be able to get that I get pay information. I don't need to pass any parameters because this gate get pay information is just going to collect. The information is already there, but it's going to return a string for display. So if I go back, I said, Okay, I've gotten my classes created. I've created the operations in each class. Okay, I have the attributes in the class, but I haven't put the haven't put in the collaborators. We're not gonna worry too much about the input device. And the output device would do that. And more events. It advanced lessons. But for now, we're just one that said okay, what's the relationship between the main employees and employee in this case here? We can just put a basics what they call an association. But I'm gonna put an aggregation relationship because what this basically is going to say is that the main function here, the main program, is going to contain a an employee object. So we're going to say, Put that in there and says, OK, we're gonna say OK, this basically then establishes the relationship that we have made employees that's going to use an employee object. So that's how we have to do to create the you mail class diagram and you notice we did all the heavy lifting over here in our analysis on and then the transport transformation of the translation of the CRC was actually fairly straightforward. Now that said, we just have to. This is an academic program. There's two classes and again, as I mentioned before, what makes a real world program difficult is not the steps we perform because we're just going to be performing the same steps. But we're gonna be doing it for hundreds of classes, possibly even thousands of classes. So again, this is the situation where complexity is driven by the size. So what we want to do now is now we have to then take this this structural diagram, which is basically our architectural diagram for our program, and then we got to see determine exactly how the main employees and the and the employees class are actually going to communicate, and that will be the next step when we talk about behavioral models.
8. Analyzing the Behavior: So how are we gonna go ahead and build the sequence Day, Graham, Remember, as we're doing the stepwise refinement process as we're going from the system description, we then went into the class diagram meld those two together to come up with the behavior of the system. So, for example, we go back to the system description and we put in If we pull out the key passage on the processing we see the company wants to the program to accept when employees name the number of hours the employee worked the hourly pay the program when they calculate the gross pay displayed employees name. So this basically tells us what we're supposed to do. Now we have merged that with the class diagram to come up with sequence diagram. So this is what we're going to come up with, not demonstrate how it works and notice down here. What this says is we have the payroll clerk. He's going to start the program. In that case here, the main employer program has to create an employee object execution, then returns back to the main program. The main program then is going to display the information and it's going to get the payroll information Once as it gets the payroll information, it's gonna set the name into the employees object. Execution returns back to the main employees. It's going to set the hours worked, and then there's going to set the pay rate, and then it's going to get the pay information. It's skin then and within the aim, the employee object. It has to then calculate it, were turned that information and then to display. So that's basically the set of behavior that we're gonna have to then modern again. Where did we get that from? We go back to our system description, tells us what we're supposed to be doing. So that's going in and show you how. Then we create this. This is a good one to do on a board before ever trying to drive begins its There's gonna be a lot of changes as you go through this. If you get this, you know, 75 80% correct The first time you're doing really well because it's just going to change as you get more and more information. So again, I'm gonna go on video and again I'm going to then put in a new page. I'm gonna just rename this page. This is gonna call to call it the class diagram. I'm going to create a new page here, and this one here. I'm gonna call the sequence Diagram. No, I don't have any symbols over here for the secrets diagram. But if I go up more shapes and begin all the tools will basically have the same same types of shapes available software, and I'm going to create a UML sequence diagram. So the first thing I could do is I need to be able have an actor Lifeline. This is the actor. So I'm gonna drag the actor over here double uh And I'm gonna call this the payroll clerk every review, the U middle class diagram. We see the Knicks object we need is the main employees object. So he grabbed an object that's extend a lifeline. Little bits of could need it. We're gonna name this and we used the you mail diagram. The main employees object make that little bit bigger so you can see it. And we're also going to need an employee object again. We create the employee object, make it a little bit bigger make sure you get capture everything in our lifeline and we're gonna call this a employee, and I'm gonna call it a employees to designate that this is an actual object in memory. Then we're going to use the system description to specify the processing. Well, the first thing has happened, the Paywall clerks can come and start the program, so we're gonna grab a message. I was down near the drill anchors of the taxes, too, and we're going to say start made. So they start the execution of the program after started in the execution program the main employee has since Stan. She ate the employee object. We're gonna grab another message and passes over here to the employees and is going to call the constructor. And we're just going to say it's gonna create the employee object. This actually passes program execution over to the employee object. And so the constructor and employee objects can execute what's it's done. It's going to return execution control back to the main program uses, start like going back, so just returns the information. Then we know that the main program that is going to display the program information so it's gonna be an internal private message and it's gonna be display program information. And then they once it displays the program information, it's going to get the pay information. Another internal private message among itself in the main program is going to say, Get pay information as it gets that pay information and has ascended back. It has to then send it over to the employee object. So we're going to send another message from the main program over to the employee object. Set the name they get noticed down here. We're not concerned at all with how these things were getting done. We're just concerned ourselves with what is being done. We're worried about the specifics later on, when we get into design and in the programming. Once it sets its name, it returns control again because, remember, set name, actually sins control over to the employer object. The employee object is going to process that name as it comes in. That says, then returned that information back. We're then going to then set the hours worked again. This is gonna set information into the employ object. It's going to do some processing to validate it once that processing in the employ object is done, it's gonna return control back to the main program. The main program then is going to then set the pay rate. And again, you're you will notice the pattern that's going here. We we set, we return, we sat, we return turns control back now once. That's Ah, the hours the name, hours work and pay rate have been set. We could then get that pay information. So we need to send a message to the employee says, get pay information. Now here the employee has to collect that information, and it also have to calculate the growth, pay those air internal operations to the employee object. So it's going to calculate gross pay. It will then send that information back to And that's sort of put this on the next line up here that's is gonna return that information pay information back to the main method, and the main method will then display pay information and in our program what we're gonna do, we will then terminate the information or the program at that point terminate application. But we called a terminate program. Make sure we consistent with the consistent with the UML diagram. So that is how you take the system description and merger with destruction. What we've done here, if we've created the behavior for the normal course of events of a payroll clerk in green pay information in that information being displayed. So now that we've created the class diagram, which shows us the structure of our program, we've created the sequence diagram which basically shows how the program is going to behave over time, where 2/3 of the way of through the analysis and design process the last piece of the puzzle is identifying the specific algorithm for functions of the operations. Otherwise, when we set the hours, what's gonna happen when we get the pay information and calculate the girls pay how we can actually do that processes in the next lesson? What we're going to look at is in how do we then specify the processing for each one of these functions? And once we've done that, we've completed our analysis. We've completed our design and we're ready to start programming
9. Creating Code Algorithms: welcome to the next lesson in object oriented programming. Functional modeling. This is actually the last analysis and design step we're going to do before we start coating and we call where we were when we first started. We were very fuzzy on what we wanted to do with our program. And then we did our class diagrams or medical parsing to create our class stock. And you got a little bit more in focus. We looked at the behavioral models, get a little bit more in focus. But now what we're going to do now, we're gonna look at the functional processing, start writing basically pseudo code for our functions Now, then, at that point here would be ready to start programming. So to this point, our analysis we've created a system description that describes a very high level of what the application is supposed to do From that system description, we parked out the objects we need along with the objects attributes in operations. We documented the applications instruction DZ unified modeling language class diagram. And then we'd link that system description and the class time diagram together to create the behavior model for the sequence diagrams now What we want to be able to do is now we want to start looking at the detail processing to this point. We've only been looking at what our system is doing. We haven't been do concerned without operations are going to work. That is what we're going to do next. That last model before programming is called the Function of Model. This is where we now look at the individual operations and to determine the detailed processing of those algorithms. Once we have completed, these algorithms will be ready to start programming as a side note. My experience shows me that this step that makes most since the programmers and actually this is the step a lot of programmers jump straight to without doing there. Now, the other analysis and design. That's because we're looking at more concrete details, which are much less fuzzy than the other analysis items were going to create the method specifications by looking at the class diagram and then one by one, we're gonna look at each one of the operations listed in the classes and create a method specifications for those operations. Where we're going to need to be able to do is we need to make sure we provide very detailed analysis for the description of their operation. And this goes back to the statement that if you can't describe it, you can't build it. So you should make sure you could have, ah, good short summary of what that operation is supposed to do if we haven't already to find it, that the data that's going to be received by the operation for passing messages back and forth. So for this operation toe work, does it need data from another object, the data that the operations going to return, that the operation is going to do some processing on the data and the object that is going to take the results that processing it's in the back. You need to identify what that is. Then you're gonna need to identify the specific algorithm, which is the recipe, where does what is often called pseudo code that defines to processing. Now, one thing that we did not do in our class diagrams we did not put in class getters and centers. Keep in mind we didn't list those because you could have so many of mood just mess up your class diagrams but we have to assume that there's going to be for every attributes are very . But we put in the classes. There's gonna be a getting centers now in the real world, there's gonna be exceptions to this. But for our purposes, for every private variable we're going to create, we're gonna create together and center for. And when we do that, these air basically just specialized method that they're going to need algorithm specified centers in particular required detailed algorithms because it is through the centers that we're going to ensure all our objects variables were always going to be in the valid state . What do we have to work with to create the detailed algorithm specifications? We have the systems description, which led to the UML cross diagram, which then led to the sequence diagram. Now what we want to do is take those two and merging them together to create the detail algorithms for each one of the individual methods, getting creating method specifications by looking at the UML class diagram, and we're going to go take each one of the classes and each one of the individual methods one by one and creating method specifications for him, for example, here we're going to start with the main method, and I'm certainly not going to show you every single one of them, using methods, specifications, template that's provided we look at each one there. The methods one by one. So let's start with the main. Yes, we have the main method. Specify the class. It's in again. This is straight transpiration from the UML diagram class diagram. We provide a description again. If you can't provide a one or two short wanted to sitting description may not understand it enough. And so you may want to think about it until you do this case here. It's the entry point for the program and controls the high level execution. The program? What triggers this? It's the program. Execution has started. We don't need any data for this program and no data is returned within specifications. We're gonna go back to the sequence diagram, and we're going to translate the sequence diagram into pseudo code. For example, we see from the sequence diagram we're going to create employees object. We're going to display the program information. We're going to get the pay information. We're going to display the pay information, and then we're going to terminate the program. So what we're gonna find is that when we then going to build this and program and we're going to use this as the blueprint to create this, create the method and that's what will be starting in the next several essence. We go down to the next one and we get pay information. Okay, that So, uh, let's get the pay information these little bit out of order. But that's OK. So we got get pay information, made employees class description, provides input prompted to the payroll clerk, retrieves the information and sets the information in the employee object. It's triggered by the main program execution. It doesn't need any data toe work. It's not returning the data. And then here's our algorithms specifications. We're gonna prompt the user. We're then going to prompt for the name. We're going to get the name, and then we set an employee, and then we do the same thing for the pay rate prompt dinner. The pay rate, we get the pay rate, set it again. Notice Down here, we're just using English like statements. This isn't programming code. It just gives us a blueprint allows us to work out the logic when we go to Cub, so I continue this process again. Here's the display programming information a terminate program again, the same thing. I post this so you could download it and take a look at it. Calculate gross pay. Here's a different one. It's invoked at the calculates gross pay, given the hours worked and pay rate have been populated, it's invoked by the pain or get pay information meth in the class and it's of the algorithms. Pretty simple again. We You see how it worked? It doesn't really need to receive any data because it's going to be using the hours working to pay rate that's already stored in the employee object. And it's not going to return any data is either. Actually, you know what? That's a change is gonna return a double, and it's gonna be it's going to be display. And actually this would be growth pay. And I'm just gonna say this is actually just gonna be return and you see how that's gonna be implemented later on and again, notice down here. We discontinue that information as we go forward Now. We talked about the centers specifically with the whole idea behind data hiding is to make sure that we only set valid values to the internal variables that may maintain a valid state for the object all time. So the set name, for example, is going to determine the input value is empty. This come from the system description, then we have the names gonna be set. If not, we need to set it to some default value. So the algorithm for that center is gonna look like if it's not an empty value, and whatever that's passed in is we're going to set it to the name. It's not. We're going to send it to some default may begin. We're not worried too much about specifics here, but and we're gonna then refine that later on. We're just looking at the general logic, but here's one for the set pay rate. It's C Center for Pay Rate, and we noticed from the system description that says, if the input values between zero and 75 that's valid. If it's not, we need to set it to some other value. So we go up to if the employer rate is greater and 10.5 on its less than 75. We're gonna take whatever value that ISS, and we're gonna set it. But if we have a value that's less and 10.5 say, for example, somebody in their zero or negative five or five, then we're just gonna send it to the minimum wage. If the somebody in there's something larger than 75 we're just going to reset it back to 75 and we do the same basic type of logic for the hour for and then we just continue in that fashion until we have all the significant methods in our past diagram created what we're then going to deal, which I will demonstrate in the Knicks in the next step lesson. If we're now, we're going to use these, actually, then become our blueprint. Where are processing would start coding, which is be the subject of the next lesson. So remember where we started. We started with the system description, and it was very fuzzy when he first started basically thin through a series of refinements . We look at the structural model, were turned class diagram behavior module to the sequence diagram and the functional modeled now and now that we've gone through, we started first. Now we have a very clear understanding of what we need to dio and that believe that that's when we leave the function model. Now what we're gonna be able to do is we're gonna be ableto take that. All that information we have and then go into the implementation and actually start program .
10. Review the Concepts: before we talk about implementation, let's talk about some of the key concepts from analysis and design that we need to then implement within our programs. Now, one of things I want to dio highlight is that in a ideal software development process, you go through a planning phase of quire ments. Now it's a phase design and coding, and he come up with some optional or some ideal plan, dent and notice down here that the time spent in these air fairly equal, probably they're going to change a little bit and in practice. But however what many developers do, they go for the short circuit planning, analysis and design and try to get into Cody and as fast as possible. There's a lot of reasons pressures to do this. But what happens in is that it? Once they're into the coding process, they have to make a lot of decisions with respect, requirements, design and knock. So also worry about the implementation details of coding, and so they're basically doing three difficult things at once, and we need any time you do that, you're typically rushed and you're going to make mistakes. So that means when you get into testing. You're going to a basically extend your testing process. And actually, you're actually, it's going to be a lot longer than what you actually planned. Now again, what students and even some professional developer I seem they jumped straight in the coding. Otherwise, they try to do all the planning analysis designed while they're coding. And what happened when you do this, you get into this. What? This building fixed mode of development, You build your test that you find an area fix after they need to do is to more and you get into this infinite loop. And so the idea is you want to design twice built once it's actually gonna save you. Time and improvement quality you don't get to the coating part is fast, but you certainly the long run. You're gonna end up with a higher quality applications Now. That said, if you want us maximize amount of time coding, if you really like coating to skip it, go straight to Cody. Not that you can't build a good program just by jumping into coding, but the risk is much higher now. Thes basic concepts that we want to talk about are essential to being able to create an optical program. We talked about him analysis. We talk about design now we need to implement it now. The first thing I want to do is we need to implement data hiding, and we're going to do that with access modifiers, the access modifiers that we're going to use that we can implement. In every programming language I've seen uses, these is private and that that is a private member that could be a variable or constant or ah, method is only accessible into the class object itself. Public members are members accessible to external objects. So we need to make sure is when we create our objects and their members that we identify them with the appropriate access modifier. We're then going to use getters and centers. Teoh access the private variables. Gate centers are then modify the value of the variable, and it's gonna contain logic to validate the inputs that ensures that are variable within our objects. All have a valid state and getters we're going to use to get those get the value of a private variable to an external object. Now then, a constructor constructor means remembered means the build or direct. Now we one remember a class is a blueprint for an object, and objects must be in Stan she hated This is a term that you can hear over and over again as you do any type of reading and research. For example, in our employees object. This is the class. This is not an object. Now, we could work with elements of this what to talk about in a second here, But mostly we're gonna work. Want to work with objects of employees type. So that means what we have to do then, within our program, for every new object or employ we have, we want to create a new employees. So if we have 100 employees were going to create 100 new employees objects and then we're gonna work our code then is gonna work on each individual object with the date of the contained. So these Aaron Stan shaded objects and then they are in Stan shaded from the class and that how these objects in our constructed do constructed is in based on what you the gal grammas you put in in the constructor. Now we do have something called shared members shared members remember our shared by all objects the same class. And they could be accessed without in Santee and objects, for example, in the example were using we have the God default name in rate these air Constance. And typically you don't need copies for every one of these objects. They basically share all those values. So we're gonna make thes shared or static objects, and we'll show you how you can then access those without actually creating objects of the class. Right? So in the next series of videos, we're going to demonstrate the building tested little approach to building optical in program. Everything we've done so far is in preparation for creating equality program. Now, if you follow each video and begin cranium program, use a building. The little testicle strategy. I think you're find you're gonna be able to build your program up with functionality in the end up with a quality program
11. Determine the Implementation Strategy: and the funds getting ready to begin. We're not gonna take our design that we created, and we're actually gonna build it. However, what I want to talk about is that you want to have some sort of strategy. When you go into program, you just don't want to do a big being type approach to start building things. You want to have some type of strategy, and then this. I'm gonna show you the strategy that I like to use. You can create your own, but you can create your own strategy. That's fine. But one of the things you want to make sure that you do is make sure that you'd have a strategy going in. Just don't want to do that big bang type approach. Okay? The first thing I'm going to talk about is you're gonna wanna have a style guide, OK? Basically, what you want to strive for is what's called self documenting code. Okay, Now someone including you can read your code and understanding the program without any type of documentation, what that means. You know you're going to create your code, and for example, six months from now you're going to come back to it, and you're gonna want to be able to understand what you did. Somebody else is gonna want to read you code. They're gonna want to be able to understand what you've done, and they want to be able to be able to do without having to go two other external documentations. So here's some things that we can do. Teoh help you creates himself. Document echoed comments help, but not sufficient for complete self document program. Right. Have a naming convention for all your members. Okay. I used the following naming convention. When I create my programs again, the what convention you uses, it is important that just having a convention. Okay, So, for example, the standard I used and typically what you're going to see it. Most developers agonies titled Case for class names such as Employee noticed down there that the name of employees is capitalize. Seeing that we know that objects air noun and announced normally capitalize. That makes sense. All right. Class members use what they call camel case. Camel case means that you're gonna string words together without any spaces. And the first word in the in the identifier is gonna be a lower case and then subsequent words after that again, No cases they're gonna be with sees. Okay, this is where the first again the first letters. Lower case, and then each character afterwards is capitalized. All right, be descriptive in your member name. So you and your reader clear And what what the members doing? For example, we're in the employee program. We're using hours work. That's a good name that's tells us exactly what the variable told him. It's the hours work to employees, but you could say hours. Okay, that's okay, but it's not quite explicit. That's not quite as clear. And it's much better than h came. And then also, while coding isn't intend to indentation vertical space to illustrate the structure of the code, we're gonna start putting in control structures and things like that. And that indentation in the white space is very valuable to important too itself Document code. Now, the good really news about this is most integrated development environments have automatic tools that going to help you with your code structure and how to use them, and we'll discuss those as we go into implementation. Now, what I'm gonna suggest again is is again. You don't want to disco build your program. Every programmer I know has some sort of logical strategy that they use building your program. They just don't go build the system. They build programs in small, logical chunks and integrate them together to get a working system. All right, so basically, what I'm gonna show is you, uh you wanna build your program and small, logical chunks of functionality and you don't want to go to the next block until the current block is not really syntax air free, but free from logical airs. So every time you move forward, you're building on a solid foundation of components. Once out, Block has created move the next logical block and you just repeat this process programing process until it's finished. For example, the one I'm gonna tell straight again you can create trick. You're your own. But just you should have a strategy. For example, I'm gonna create an empty project. Just create this. Make sure that the empty project all the libraries air done, everything is built, everything's in integrated, linked incorrectly before it starts. Our before even create the first main class, and I'm gonna go ahead and create the main class. And within the main class, you're always gonna have a maid method. Main method, um, again is going to be the entry point into your application, and it's basically going to be the main controlling unit for your applications. So I'm gonna build that within the main class right off the bat, and I'm gonna make sure it's gonna make show. At that point, I'm gonna build that, execute the project, and here we might even see a working program. I put some dummy output state. All right, so then I don't really start building out the actual class diagrams sequence diagrams until I know I have a working shell of a program. Then what I'm gonna do is I'm gonna go in and create modify the application overhead method . Every application I've ever worked on is gonna have some overhead things. For example, what we're doing is we're using the display application information, and we have a terminate program terminate program method. And so I'm gonna go build those out, and I'm gonna integrate him into the main class, and I'm gonna work on that until that works. Now, at this point here, then have a working program shell over program. The main method works. I have my overhead methods completed. I could test it. And now, once I have that, I have a good foundation to start building on my classes an object. So I start creating the class show again. You're gonna want to have some sort of strategy And what classes you're gonna build first in our program. It's going fairly, since we only have one or two. But then I'm going to build out that class and I build out the shell. I don't put anything in it except for the variables. Okay. And then I basically go ahead tests that make sure it works within. I integrated into the main method. Once it, it's that classes in the greater than the main method, I'll go up, and then our start creating getters centers for the variable, and then I integrate those test those into the main method, make sure they work, and I keep in this loop until I know that I could retrieve and set data within my objects. And once I have that not, uh, take each method individually, work on it, make sure it works. Integrated the main program. Just stand this loop until that method works. And then I just continue with the method. And then once that's done, I go to the next class and go ahead, integrate that in again. This is the sort of strategy I'm going to demonstrate in the next couple videos, okay? And by doing that, you also want to make sure that you use the tools and the greater development. Violence have lots of tools. That's gonna make program cheesier. They have a tool called Intel a sense. Okay, this is going to help. You may remember identifier names, proud of and parameter list. And the one thing I point out, if a variable method doesn't show up in the Telus in something's wrong stopping, fixing compilers you're gonna have all sorts of formatting tools that are gonna allow you to do automatic horizontal vertical spacing saying so you don't necessarily have to think about all the tabs. It's basing toe set up for you automatically when the most important tools is the real time compiler. Now, one of the hardest things, particularly if you're just beginning programming, is getting this syntax correct. Now the real time compiler will check that syntax. Make Aziz. You type it in to make sure it is correct. Okay. As you type in each line of code as he finished that line, do not move to the next line of code until the line you're working on his free of syntax airs. That kind of means you may have to stop and look and do some research on Go slow you down. But what you do not want to happen is do not let errors buildup in that problem window. If those syntax errors build up, you're going to reach a point where you may as well just start over. You've got 30 40 errors and they class of 100 lines of code. That's all 100. And you may just may as well just start building a class over again. So don't let those errors buildup in the problem window. The other one is You're gonna have an integrated Ah, development is all have the buggers. The buggers is the compiler looks for syntax errors. Otherwise, the things that going to make your program errors that prevent your program from compiling and executing a the bugger then allows you to look for logic airs logic er's are your program is working, but you have an error in your agua them just giving you, ah, invalid results. So the bugger lies you to step through your program line by line, watched value variable. Watch how the program controlled moves from object object and you could use to find program . And you use this to find programming logic errors. And not only that, it's easy. Good educational tool because he could do the stepwise, the bugger. And you can see how control is passed from object object and how values air changed. All right, so the next series of videos going to demonstrate that Bill little testicle approach everything again. Everything we've done so far is in preparation for creating a quality program. Okay, Now, if you followed videos, uh, the creator program using this bill little testicle approach, I think you're going to find programming on a refund. But it's gonna be you be more successful as well
12. Setting Up the Programming Environment: This is where the fun really begins. We're going to start coding. What, as you call what we've done is we spend a lot of time with these creating these class diagrams. This class diagram in the sequence diagrams are going to be your primary blueprint for creating programs. What we want to do in coating is we want to translate this task that this class diagram as well as a sequence diagram and that's gonna be our blueprint to then go ahead and create our program. Remember, when we put our kratom created these class diagrams, all the symbols have meaning. For example, what we're interested now is the minus sign basically means that it's a hidden. And so we're gonna have to use private we anything that's plus is going to be a public. We have our class name employees here. If we have a method that's named is the same as a class that is the constructor. Okay. And as you recall, what we're going to then do is use that building little testable approach. For example, in this video, we're going to create the empty project, great the main class and create modify the main and We're gonna make sure that we have a working environment before we start building it up. Well, let me go ahead and set that up mirror call. My tool of choice is gonna be visual studio community free download, and I'm gonna be in C Sharp project. So first thing I want to do is I want to create a new project. In this case, I'm going to create a console application using C sharp click. Next, make sure that you ah, save where you want to store it. Otherwise this could be hidden from you. I'm gonna, for example. I'm just going to say this in the download folder. It's It's a temporary file for me. I'm I'm going to give it a name. A calculator? It's brought version one because I'm gonna create the different versions to demonstrate thing. Quick create. Okay, So you noticed what comes up. You notice that visual studio and other languages will do this as well. Not just There's our visual studio notice. It's created the program for me automatically. It's already created my main function that's already put out a statement. And but if we go back and look at our to be correct. We basically wanted our main class here. They call it Program Week. Want to call it me? Main employees. I want to change that again. This is using the tools I want to rename that too. Main employees can't see behind their hooks. Spell that right? And then I want to say OK, going. Any comments? Make change, Name. Click, apply. And so now I have no notes Down here, the file name is different. So we when I actually Bobby changed the file name too? No. Some languages like Java. Make sure that the file name the class name and exactly same. Not true in C. Sharp. Right. So now I basically then have I've done this. I've done this first part. Now let's go ahead and make sure it works. So what? It's build it. I'm expand this out so you can see a little bit better, so I'm build it build solution game. And here's the output build. Succeeded down here a notice down here if you want. Teoh, Look, make sure that you see have your problems show up. Make sure that you have your error list displayed. So, for example, I would It's not display by default. I want my air list displayed out there. Here's my air list. And so what's going to show up? And this is what the real time compiler looks like that. So go ahead and type it in myself. So notice down here. If I delete, that's like to console notice. That's the intel essence. Okay, I so I don't have to actually type it now. I hit Tab and it auto fills. I want a right line on those down there. It looks ahead. I do the one I want to select the world and noticed down there's we look at this. That little squiggly there is the real time. Come, palaces. Hey there. Down here. You need a semi colon. Semi colon. Right. So now here's the output window again. Let's go ahead and build it. Build succeeded. Okay, now I could go ahead and execute it. So I go and execute at this point, and then I see a pop up. Okay, So what this means is now I have a working environment. I could then expand and we're start looking at how we then translate the rest of the the class diagram into the
13. Build A Little Test A Little: Okay, let's take the next step in building our program. Remember what we've done so far. We've taken the creator empty project. We raided the main class. We have remained method working. Now, the next step is ah, again, in the process that I'm using, I'm going to create the overhead methods to make sure that I have working program. Okay, So if I look at my class diagram what is that? That means it's the display program. Information and the display Terminate program noticed down here, these air they enlisted are underlined, which means that they are shared objects. Okay, so we're shared method. I'm sorry. All right. So let's go ahead and build that out. OK, so now we remember in and And this is true of every object or language is that here's the class. Everything we define has to be defined within that class and notice down here. Intelligence tools basically show. Okay, wait a minute. This is the end of main class. And so click on those. It would always show you the matching breaks again. I d specific thing. And you don't want to cover that now. Just make sure you learn how to right. So over here it says we want to display the program information. So now we need to create it. And over here it says it's private. The underline means it's static. Okay, so I'm gonna just got to clear that, just like it is. So it's gonna be private in the nose down there and tell a sense pops up. You could either type it out or if I hit space or tablets, very. At this point, it fills it out. Notice down there. Blue means it's a GTO. Observe word and green means it's a It means it's a class. Okay, so I have a private I'm gonna declare. This is static. I'm not returning any value. I did notice down there. I could tell by the display that it doesn't return a value on notice. Down here, these were turned values. So I declare this is void. Most programming languages will use the same syntax and then I desk type and display program information. Those are off. Now that I have the method signature declared, I'm gonna go back to my our rhythm specifications for the actual algorithms and code that I'm going to provide within that function you notice in the processing specifications for the display program information display A prompt where we're going to welcome to the pay calculator program that we're gonna prompt. It says it calculates to pay for an employee, interred employees, and it's gonna provide directions. The intern employee name Ours worked in pay rate, and then it's going to calculate the girls pay will be displayed. Purpose. Just gonna go ahead and cut paste the code that I have and this'll bigger in case notice down here. It says string builder. This is a show potential fixes. Okay, now, this is one of those cases You want to make sure that you, uh, correct. There's before you go for this is also where the power of your i d is going to come in. So, for example, again show potential fixes for this air. Could tell it's a nearby, all squiggly lines. If I list their list, you could, uh, I see it. I'm sorry for the small size, but right. So what you do, you go to our show Potential fixes. And it says using system text came This basically then is going to import that library in I select that notice down there. Turn green. That means it's recognized it. And notice down here, it's It's linked this into the top. Begin the most other modern programming environments Do the same thing. Provide those fixes for U S O. Take care of that. Or make sure that you learn how to use those environments again. Now that I have this. Okay, I created this. Do I want to go to the next one, or do I want to look at this one first? Well, let's look at this one first, okay? We can go ahead and leak that. We don't need that anymore, because we have our environment. Now, I want to invoke this display information from this method. So display and notice down there that the intelligence pops up. Okay, so now, once let's go ahead and look at that again. Display type from beginning display notice Down here, it looks ahead. Clicking on it display information. So now at this point here, I've got it. I can go ahead and build it. I don't that's gonna build automatically anytime you runner, by the way, it pre built it. But that's great. And build a solution built started now I could go and execute, and I get my, uh, display message. Okay, so that part works. Okay, Now, I look over here says, now let's terminate program information. Now, I'm gonna go ahead, put in private notices there again. It's private. You could tell by its private by the minus in front of the identifier in the class diagram . So it's private. It's got to be static. It's not going to turn any values. And the name is terminate program going quick out open and close it. And again, at this point here, I'm not going to have you watch me type code. It's painful enough, and I'm gonna go and type that in, and I don't believe I think I need this one now. So now I have it. Right. So now I get that I don't have any error lists, OK? Notice down here. Both. For example, I had miss so, uh, no sound. You're going to see it squiggly. Okay, it's gonna tell you where it is, so make sure that you pay attention to those ares is You go forward. Music can save you a lot of heartache. Okay, so now I'm gonna go Put a space in here. Now terminate at for terminate the program. Call it from there. Go ahead. And now again. It rebuilt it every time. So I executed. So here's my display message. Terminate the program and he keyed Exit and them done. Now, at this point here, where my in my process again. If I look at my process here, I have prayed to the empty project. I've created the main program and I've created the overhead methods. Now what I could then do start building off the class show and our world will do that in the next 50.
14. Creating Your First Class and Object: Let's continue coating the nodes where we are. Remember what we've done so far. We've created the empty project. We created the main class. We've created May main method. We've also created the application and overhead methods. And at this point here we have a working program that displays the overhead information and terminate program information. Now, what we want to do is we want to start building up to class. Okay, so in this case here, we're going to start building out the class. And again, we're not going to wear Diskant, build out the shell first with the constants and variables. And then the other thing that we're going to do to actually to be able to display that information, we need to be able to collect it. And we're actually then gonna add to get pay information as well. So then we could display it. Then we're gonna integrate that into the main program. Okay, so let's put that aside. And then let's go ahead and build a class A new class and again, this how you building new classes going to then depend upon your programming environment. But what we're gonna do here is we're going to click on the project. I'm gonna left click. Sorry, but that quick on the solution and I'm going to add new item. It's gonna come up. So what do you want to add? I'm going to scroll down to visuals. Vigil sees sharp class. I'm going to give it a name. And I the name I'm giving this. If I make sure that we follow the the class diagram is our template. This is gonna be employees. My click add. Now I have a class here and notice down here. It's Ah, put it here. Now. One of the things here is that we want to then rename this because that just named the file . We need to rename it the class, and it's gonna be employees again. All this depends on all this. Depends on the environment. So we have our class and notice down here, Actually, even puts in a default constructed for you as you do it because it basically assumes everybody should have a constructor. So now I'm gonna go over here and make this a little bit bigger so you can see it, but Okay. So now what I need to do is I need to create a default. And then I'm also going to create this get pay information down here circuit, actually see that information as well. So let's go ahead and build it out. And I'm just gonna type in one of the declarations. So we noticed Public constant against of whatever language you're using, It could be different. It's gonna be a string value, and it's gonna be default name. And again, I'm just using the template over here in the class, Doctor, In this case, I'm sorry, Constant. And it says not given. I'm just gonna We decided to put on all this stuff here, right? And so again, I will then would do the same thing. I would just follow that same process and declare all these and again I'm just gonna copy and paste. This sees these in. Here's it's like watching somebody else. Titan coding is absolutely painful, particularly me when I have fat fingers. All right, so now I basically have those that information, okay. And the other thing I want to do is I want to then type in the variables. Okay, so that's appear. I'm gonna type in the variables notice down here everything. And this is true. Every language has to go between that classes. That class definition here is in a class where everything has to go in between these these outer indexes or these outer brackets. Okeanos down there even shows you if I click on him. What were the mattress matching brackets are again? So now I'm going to use my Templar over here, and I'm going to create the No. I'm going to go ahead and create the variables nose down here that these are not static. They are private. Okay, that's they're not static because they're not underline. And the miner says that they're private. Okay, so I'm gonna quit private and then string and I type in the employee name and in this case here, I'm not going to initialize it and nose down here. I would do the same thing for the pay rate in the hours worked. Okay? Now, one of things I want to dio is the constructor. Okay, these you know, it's general principle that variables within should be in this life. So I'm gonna go ahead and take these variables, and I'm going to give them a new initial value. It's kind of one of the things that constructor could dio do many things. But this is just one that I'm, um, pointing out is that I'm going to use employee name and notice down here. It's once it's highlighted the tele since look looks forward, hit, enter and I'm gonna say default and notice down there it found it. I get tab And then again, I want to Pay rate is equal to and I want I'm going to say the pay rate is gonna be initialized. Men rate the tab, inner. And then hours worked is equal to us. A men hours zero. All right, so now that's kind of illustrates kind of water constructors going to do now. I can't really get in it. Have you any of this information when I go ahead, test it because everything's private and I haven't created the getters and centers yet, but there's always I don't say always, but in most cases you can have some type of function or method that's going to get the information. I'm gonna call it, get pay information in this case here, so it's gonna be a public method. Public is called get pay information and I should probably say it's going to be a string the attention to what's over here and now what I'm gonna do is I'm gonna collect all the information of daring. Now it says that you're going to see there's an error in here. It says that not all code path returning value. That's because I have to have a return statement in here. And I'm just going to go ahead and copy and paste to code again. This show you could positive video and build this out if you want, but basically what I do, what I'm doing here is I disc elect the information notice down here. I get that same year before because I haven't linked in the text file. So I go to potential fix moves, go to show potential fixes, and I need this system tax Do basically reference. Right. So now I basically have a basic shell of my program or my class employees class. Now, I could actually go back my main program and I could actually use this, and this next step is very important because this is the first time you're actually gonna and Stan she ate on object. Okay, So let's go back the main program. And again I'm using my my class diagram is a guide. The first thing that says the main employees class has to have a variable called employees . Now that I have created employees, I could actually just create a variable like that. And we do that dislike we've done before. You notice it's private underlying means that static. And if we're gonna reference it within the main program, that means it has to be static. I think so. We're gonna private static. It's an employee object, the data type. And then I'm just gonna give it its name. A employees, right? So I have my first employee Now I don't want to do is I want to be able to display that employee information. So again, I want to create another method, and I'm gonna follow over here to display the ploy Employee information. Now, the whole idea here is that remember, we put all this code we encapsulated putting all the information to get gathering the information, providing the information within the May within employees class. So also we need to do to display the information is to invoke and call the get pay information from the class. So what we need to dio is again I'm gonna create a function just using my guide. Over here is display information. It's private. Okay, it's static. It doesn't return in the information and display program information. Now we could access now, since this it's declared in the same class and it's private, we can access. It's a same play. A employee object without having Teoh Du Passage in is a parameter. Okay, so for me to then too access that employee information we're going Teoh type in council we want to display to the council. We're gonna do a right line, we say, Okay, I have my employees object and I'm going to get the pay information. You know, it's a function call or method call, and then I go ahead. Now, that looks good, but let me show you something. I did this on purpose. Now, when I go to execute this old first of all, let's go to execute this and displayed it, and I'm doing this on purpose. I made a mistake on purpose to illustrate one of the things that you're going to see. Okay, so now I go and execute this. And even though it looks logical, once I execute, I'm going to get a runtime error. Well, let's try that again. Because obviously I made an error that winter I made okay. I didn't buy displayed the display information again. Get what I want to do is actually and I even change this wrong display Pay information. Begin. This illustrates this illustrates the problem where the build a little test will approach. I work on the problem where I tested. I work on the problem until I get it fixed. But what I really want up here is display pay information. Okay, Now, once I do this again, it looks good. Okay. All right, let's try it again. Go ahead and execute it again and notice down here, I get a runtime air, and this is when you have to pay attention. A employee is equal to know I'm gonna go ahead and stop execution and what that air means. And when you see that, remember, What we have to do is that when we create an object, this just basically declares an object. But we haven't in Stan. She hated the object. Yet this just says I haven't object called a employees, but I haven't actually created in memory yet. So appear when I do this, I need to do new employees. This is absolutely necessary. There's two steps of when you want to use an object. You have to clear the variable. Then you have to stand. She ate the object to separate distinct steps. One of most common mistakes that introductory object Korean programmers make declare the variable, then in stand shaped variable. Okay, so now the could actually cute this. Now I get I get my program information. It's not given. Here's all the defaults, I said. So now what I did then have is I have a working program working shell of the the employee class. But now what I now need to do is do the internal processing of the employees class and not be ready to go. Just using that bill, Little test will approach, and we'll continue that in the next video
15. Build Robust Getters and Setters - Part 1: Okay, here we are in the next step of building out the classes is if you remember where we are, where we've done. We have our project. We've created Main Class. We've quick rated the overhead functions. We basically created the class show when we're able to actually work with that class show within the main program. Okay, Now we want to basically build out the centers and dinners. Now, we need to be able to collect the information from the user, be able to set that information to the class, and then we could then continue the processing. So if we look at our class diagram, we see that we got to do that in two different steps. Okay? The first step is we gotta basically create the getters and centers for the object or for the classes, private methods. And then what we have to do is we have to be able to get that information and from the user and actually boasts it in again. We're going to use this in a criminal way and would do the employee name first. They then were built out to get pay information for that. And then we're at the pay rate. And then we add the hours work and would just incrementally built it up. Okay, so let's talk about getters and centers, Okay. Now, for example, let's do the getters in centers. The whole idea behind the getters and centers is Babe, babe to have these private variables. And when we set that information, we want to make sure that that information is correct. OK, so let's go down here and let's go ahead and create the first center for the employees class. Okay, now, one thing we noticed we mentioned is that notice that getters and Saturday aren't necessarily listed on the class diagram because it's assumed okay that by default, if you have a private variable, Met member employees pay rape that you're always going to create getters and centers. You don't always have to. But it's basically the fault is that you're going to create him. So the first thing that we're going to do is let's go ahead and create the getter for the kid employee name for public. Okay, I'm gonna have to return a string value, get a notice down here. The standard for the guide says employees name. This is a standard way to name getters. And then all we're going to do here is return employees name easy enough. Now it gets the more difficult. Now, when we said it, we actually want to make sure that we have valid values. So again, we're gonna public. Okay, this a center does not return any value. So we're going Teoh say avoid in the stand or the is to standards set employee name used, a term set and then the name of the variable. That's typically how it works. Now we have to say, OK, what value were being passing him? So I'm gonna say that what's gonna be passed in, what's going to be passing is going to be the name of the employees. Okay, so we go in there, So now we have to double check what makes it name value or string value. Well, it can't be empty. So what is the logic of determine whether a value is nowhere empty? So we remember when we go back to our processing specifications, we've created the pseudo code for the set employing name. So we asked ourselves if the employee name is not empty, we're going to set whatever's passed into the name. If it is empty, we're just going to set it to the default name. So what were you going to see? Here is the translation of the pseudo code to the actual C sharp code itself. What we check here is Is this name Knoller empty? And we do that? Not so. If it's not know Knoller empty. We set the input value to the employee name. If it is no empty, we said it to default name. So the logic here probably isn't super. You probably want to expand this in the real world application. But the point here is that when we create thes centers, we're going to make sure that we validate the input so that the variable employee name and the other variables that air private to the class were always going to be in a valid state . Now that we've created this center for the employees name, what we want to be able to do using our building a little test little approach is actually go and test it. To make sure work properly, we go to a UML diagram. That means we have to start building out to get pay information and we'll build this out and just test collecting the set employee name set in it and seeing if we can display it properly. Now keep in mind, we've created the pseudo code and the logic for what we want to do it to get pay information. Now we just want to build this out incrementally. And for this sacrament were prompting for the employees name. We're going to get the employee's name, we're going to set it and then we're going to see if we could display it properly. Okay, and since I'm just working with the employee name at this point, let's just worry about that one. So we're gonna need to write a prompt to the user toe an undersea right again. Double click on it. No, you see, enter employees name. Okay, there's my prompt to the user, Twig Lee says you need a semicolon there, and now what I'm going to do now I'm going to collect that information from the output and then actually going to store it into the employees object employees that my object that I'm working with again I have my set name and now I'm going to say OK, read the council and store what? I store what I have in that element. Okay, so now I'm just doing the employee name. All right, so now I have display information. I'm gonna go back up here now and now I'm going to say get pay information. And now this case here I can disc elect test dog and setting the employee information. So now if I go ahead and test it executed, get an employee name Billy, and we see the employee name was set. Now, here's where the do bugger can really be. A nice tool for learning do is I'm gonna set a brand going to said a break point here, which is and so now I'm going to set the do bugger. And so we could watch how things work. No, I execute the program and you notice down here Sarkozy's We don't need those. It stopped execution at this point here. Inter employee name. Right. So now I go ahead and I go ahead and step into it. This is the debug step showed next statement. I could watch what happens. Sorry about that. Pushing the wrong button. Okay. The inter employee name I put in Billy. And so you notice down here, we see that it's jumped. Execution control was passed over to the employee object. You can see down here says, Here's the name. This is the object that we're working with. There's the name I could view it. I could then step into it again. Okay, now it goes and checks to see if Billy is. What's being passed in is no more empty. It's not. And then go ahead and we see that it gets named Check that that sets the name correctly, and then it steps back out and control. And then again, if I hit, continue. Right. So that's one of the 1st 1st exposure to the buggers. I suggest that you try to use that bugger to actually see how Program Control was working. Um, and then we're shows more examples. We go forward
16. Build Robust Getters and Setters - Part 2: making progress. So where are we in the process? Here now remember the process, what we've done? We've created the empty project. The teachers, okay, Before he moved on, created the main class. Begin. We made sure that work Before he moved on, we created the application overhead methods. We created the class shell, and now then we bait. It's basically created Our first center with the name Now we want to do is we're gonna continue in this loop and create other centers and getters for the class variables. So, for example, go and make this a little bit bigger. Let's go ahead and create the getter and setter for pay rate and dislike. Result done before. We're going to create a get her first, and it's gonna return a double value again. Noticed that naming convention with get and then the name of the variable typically, what you're going to see in applications and we're going to return the pair A as we've done before, we're going to go back to their algorithms specifications for the set, the pay rate, and we're going to translate that pseudo code into the actual programming code. Remember, we're getting the pay rate in past in. So if the pay rate that being passed in is greater than men rate and less than the max rate , otherwise it's within that valid range. We're just gonna take whatever has been passed in, and we're going to set that into the employees pay rate if it's lefts and the men rate. Otherwise the pay rate is, say, negative kin. We're going to then just reset the pay rate to the minimum rate allowed. If it's greater than the maximum rate, say, for example, the 150 then we're just going to reset it to the maximum rate. So let's go ahead and just I just go ahead and copy and paste the code in so you don't have to watch my fat fingers type the nurse what we did here. We bring in the value that's being collected from the user. It's a double rate. We make sure that spits between the minimum rate and the maximum rate. If it is, we go ahead and set the local variable or the variable in the object to that values passed in. If it's less than the men rate, we're gonna go ahead and set it to the minimum minimum rate. If it's greater than the maximum rate, we go ahead and set it back down to the maximum begin in real world application, this is gonna be a little bit more robust. Ah, but you get the idea. So let's Then what do we do now? What we need to dio is now we need to go ahead and put in the code to actually collect the input from the user. And then So we're gonna joke, jump into the main method. Following are process. Let's go to get pay information pseudo code and see what we need to translate into actual programming code. So we seem to get pay information. We've already done the employees. So now what we're gonna do for the pay rate as we're going to display a prompt to the user , we're gonna have the user input the pay rate. Then what we need to do is we want to validate that the pay rates of number, for example, we don't want something like, Ah, valid number would be something like 34. That's a valid input. But if something the user in or something like that's garbage and that will cause your program the crash. So we want to make sure that this input that's provided his actual number. If it is a valid number, then we're going to set the pay rate in the employee class. Otherwise, we're going to display in their message. Let's then see how we translate this pseudo code in the actual programming code. Okay. And again, at this point here, I'm gonna go ahead and just copy and paste the code and explain to you what's going on. So we go back into the get pay information and I've put in some temporary variables in here local very moves in here so we could make sure that we could collect the data and validate to data and pay sack coat in. Go ahead and pause the recording to look at this. But there's a couple things I want you to notice. We're going to do the council right line that notice down here, we want to be able to provide a prompt the user on what they should be entering its a pair A between some minimum rate and the maximum rate. This is where the concept of a shared or static variable comes in. If we go back to our employees class, we noticed that we then put those is public, Constance, these air, then static. And then I could then access sees without actually creating the object. So that's what we're doing with the static now. I don't have to have a natural object to get these values exist to the employee class. And I could then just reference each one of the individual individual data data points that I want and notice you could do this with within ecstatic methods or any anything other static member that you've created, right? So in this case here, we're also gonna do some validation input validation on the code at the interface level. First of all, we're going to read in the string again with the same thing. We got to remember that everything that's red in is coming in is a strength. So, for example, if I want to type in the value of, say, 54 what's actually read in by the system is the string representation of that number 54. Well, that's not a number. That's a string, what we really want. We want the value 54. So we then have Teoh parse at value into the you know, parts add value into the actual number 54 now and C sharp and again, every language environments committal but different. What the stripe parts does it checks to make sure that you didn't put in junk? For example, if the user input junk okay, that's not a valid number. And if you try to parse that if you try to Pursat, then your program is gonna crash what this parts does. It basically says we'll make sure it's a vow and actually a number. And if it's not a number, I send out an error message. But if is a number one okay, set the value. So now, at this point here, I've put in the pay rate. I've set the pay rate. Now I can go ahead and execute the testament this out and go ahead and test it out. I an employee named Oy, we asked what the pay rate ISS say. 54. Looks like I need to put a space in there and notice down there. We got the pay rate set, so I'm a calculated anything yet because we haven't done the calculations, but I'm starting to get the data that's coming in. All right, So what I need to do is also is I need to put a saying colon at the end of this in a space . So there's a space between the input in the output, right? That's sort of illustrates one of the reasons why you didn't do this Bill little testicle approach. I make sure that this one's correct before I go to the other one. Right. So the other one, the hours work, the logic is exactly the same. So what I'm gonna do is that's go down now. And we're going to enter the create to getters and centers for the hours work and like before, just go ahead and create the code. It's the exact same structure in the exact same processes we did with the pay rate. Most down here. What? I have the set hours worked. Okay, Um and then where I bring in the hours if the hours is greater Neagle women hours. Okay, I see. And it's less unequal. Max hours, I said, what's passed in otherwise, if it's less than the minimum hours, I'm gonna accept, I re sent it to the minimum. If it's greater than Max, hours are going to set a reset it to the maximum, and we have to make sure also to same time, which is we need to make sure that we have the getter in there as well. So I have to get her in there. And now I'm gonna go back to the main employees. And now I'm just going to then basically reproduces, coded. But except for taking in the hours worked, I'm sorry. So as we see here, we just have the basically the same exact logic. I used the static methods in this case to Constant, to give me the minimum hours and then the maxim our So I can provide an output to the user and noticed that I'm here. Did I need made that same little air I made before? So let's go ahead and correct that I read in the value I try to parse it again. The idea here is we want to make sure we get a number and not some jump in the string if it's valid. I said it. It's not. I just basically provide the user with their message so not Go ahead and test it. It's an employee named Billy. Ours works 50 hours, $25 an hour and notice down here. I've got the Billy 50 hour or $50 an hour in 25. 25 hours worked. All right, so now at this point here, what I need to do, I haven't done the processing. And the next step they go into the class diagram and then go out and build the methods. We need to actually process that data once we've collected it. And that's what we're going to go in do in the next increment. - So not go ahead and test it. The employee named Billy ours works 50 hours, $25 an hour and notice down here. I've got the Billy 50 hour or $50 an hour in 25 25 hours worked. All right, so now at this point here, what I need to do, I haven't done the processing, and the next step, then, is to go into the go into the class diagram and then go out and build the methods we need to actually process that data once we've collected it. And that's what we're going to go in do in the next increment
17. Build the Methods/Functions: almost done. We have one more thing to do now. Getting, remember where we are Make this a little bit bigger so everybody can see it. We're at this point here where we've implemented all the getters and centers. Now what we need we want to do is we want to be able to actually create the methods. And the only method that we're creating in this class or this of program is a calculate gross pay. So now I need to go calculate the gross pay integrated into the main function. Now, the really nice thing about this function is that I really don't have toe update the main method anymore. Since this is all encapsulated the pay calculations, all encapsulated in employee, I can just do everything here. Okay, so I'm going to follow my UML diagram, and I'm going to go ahead and then dis implement the pay calculator program again. That's going to look like this. It's gonna private double calculate gross pay, and all I do is return the hours worked. Time to pay rate. Now, keep in mind, I could use these here without passing because their private members of the ob of in this class an object. So anything that I have declared at the class level, which I have at this point here, and we could look at it over here, anything that's to quit with the declared at the class level here is now accessible to him . And I don't have to passing the data around. All right, so now what I just need to do now, as I need to do, is an update to get pay information to then calculated each time I after each time I've set , um, the hours worked in the pay. Right now this is fairly easy. All they need to do is I just added this a pin line I put in the output statement gross pay . I then called the method calculate growth pay. Now, remember, anytime I'm putting something into the string builder, it's got to be a string. So I'm gonna turn it the string, and here I say it's gonna be currency format. Now, that really nice thing is now, since this is all encapsulated inside the employee information, I don't really have to do anything to the main. Um you mean employees class, because once I've collected it, okay, Once I've collected all that information, I'm just going to display the information into a calculator for me automatically. Let's go and look at it. So it's gonna be Billy. Hey, Billy. Work 50 hours this week at $45 an hour, and we noticed that he earned 25 2025 $250 for this week. Terminate the program. All right, so what we've done here, we've actually completed are programmed. Once you've gone through this entire process, were basically completed. Our first generation of the program. Now we're not done at this point. We didn't test it sufficiently to really check all the past. We didn't test it to see what happens when we put in garbage data. We didn't test of what happens when we put out a range data. Otherwise, we put a negative 10 or 150. But that would be part of the testing process. There you continue. So basically, that's the process. Remember? Two DUIs. You of the bill little testicle approaches that you The one I'm doing is that you create the main program. Okay. Empty project to make sure it works. You create the main class. Make sure that works. You go in and build the in the overhead methods, and at this point you have a working shell of a program and then bit by bit, you create each class that you go into its class you're going to and building, integrate into your system. You integrate that into the main meth, make sure it works, became and that's this a shell. Then you go to the class, you build each of the getters and centers incrementally integrate those into the main method came until that's done and then you create and modify your methods. They're actually going to do your processing you need. And then once that's done, you go to the next class. So what we're gonna do is we're just going to do some final thoughts in the next lesson and what I recommend that you do. Did you practice this much as possible?
18. Final Thoughts - Things to Remember: Hello. Welcome to the last lesson. An object. Korean programming. In this lesson, I would like to provide you with some final thoughts, and I hope to show you and convince you that while actual programming is very important, since you can't create a software application without being able to program. But his introductory programmers, I believe it is just as important or even more important, that you understand that your underlying concept as you'll find programming skills are perishable. And if you don't practice constantly, the new skills will fade. However, an underlying understanding the concepts will stay with your long time. And then when you start programming again, or if he switched to a new language, the Conceptual Foundation will help you pick up the program. It's goes much more quickly. As you probably know, technology rapidly changes in the software engineering world. We get new languages and new development tools every couple of years. Some of the newer languages or go long python has been around a while, but it's fast becoming very popular. Language. Language is on the decline or obsolete, or pascal visual basic six small talk for a trend and so on. Also the tools of all morph together, he clips Net beans, Microsoft Visual Studio, the tools I used. I'll have the same basic set of operations they all have formed. Designers tell a sense real time compilers, project Explorers auto co generators and source code control. If you learn how to use one of these tools, it's gonna be much easier for you to pick up the other tools because they're so similar in terms of the interfaces in the operations. On the other hand, underlying concept to software development while they have matured over the years, haven't changed dramatically over the last few decades. The biggest change. My career's When we went From Structure Programming, Job Victoria programming in the early 19 nineties and two thousands, the basic obvious Korean concepts haven't changed much sense. Also, consider how many language have derived just from the C programming language C plus plus Java, sea, sharp python, javascript. As a result, they all have very similar syntax. Other languages use the same basic control structures of the same. They'd all use sequence selection, looping functions and parameters and then, on the other hand, as we moved, robbed a Korean programming the concepts and even though the overall development process is the same for every language and every tool. All the different languages. Java C C plus plus C sharp python. They all basically use classes and objects. They use encapsulation of data hiding he's inherited. As I mentioned, implementation skills are important. You need to know how to program. However, it's just is important or, more important, to understand the general concepts and processes than that is the actual programming language, particularly as an introductory programmer, the concepts aren't gonna change. Only implementation details changes. You go from language to language that's looking example. Here's a basic academic program that's going to draw shapes on the screen. You notice is he look atyou. Mel Class diagram. There's nothing in the diagram that's best is far specifies what programming language. What I have been going to show you then. The implementation of this program in two languages, Java and C sharp, And what you're going to see is that there's very little difference in terms of the structure, their program and particularly between Java and C sharp. There's very little difference in the overall syntax of the programming language itself. So here's the shape program, one built in Java with net beans, the second built in C sharp with visual studio you noticed very quickly. There's a similarity between the tools. Both tools have a solution. Explorer, that list of files. I noticed the name of the classes or the same notice down here that packages air similar. Both have a shape and utilities, shape and utilities. If I look at one of the files in C Sharp, we noticed we've seen this type of object before. But if I look at the circle class and Java, you notice it's very somewhere in structure. It's very similar in syntax. If I look at a square class, compare the two you notice again. Very similar in structure, very similar in syntax. If I look at the main program for each no, it's down here. It's very similar in terms of overall structure and how the program executes. So the point I want to make here if we look at the implementation, they're very similar and very in structure and very similar in syntax. So understanding the foundational concepts makes implementation much easier. And if you go between language to language, if you understand those concepts your life becomes much easier and you'll be able to make that transition much more quickly. So what's next in your object or programming journey? In this course, we covered the basic concepts and implementation of object during programming design. These are fundamental concepts necessary for you to do more advanced programming in the intermediate concept and techniques. Course we'll talk about composition, where classes made up a several smaller classes like an engine of a car, is made up of many smaller components that is, the engine block pistons, fuel injectors and so on. Inheritance is the concept of creating parent classes that contain common attributes and operations and then allowing sub classes to be based on the parent class. And then the subclass can then specialized. The behavior. Yeah, the concept of polymorphism. That's the tool we used to allow sub classes to specialize the behavior of apparent class operation. By allowing the subclass to override the code of the parent class, overloading allows us to define operations with the same name. That, except different data inputs after our classes, is an extension of inheritance where we create a parent class but never have the intention of creating an object of that class interfaces allow us to enforce a set of behavior on objects in order to provide consistency in the implementation of the class and processing of the advanced techniques air creating graphical user interfaces, database processing and design pattern. Well, this is the end of the introductory object Korean program course, and I hope you enjoyed the course and good luck in your future endeavors.