Jump to content
xisto Community

robinhood1405241508

Members
  • Content Count

    8
  • Joined

  • Last visited

About robinhood1405241508

  • Rank
    Newbie
  1. Hey, I'm interesting in what's coming, please keep up the good work Sincerely appreciate your work.
  2. Chapter 2: Introduction to Object Oriented Programming There is a famous story about a professor who goes to meet a zen master inquiring about zen. The zen master welcomes the professor to his house and they sit to have tea. The master starts pouring tea into the professor's tea cup and keeps pouring long after it has filled up. The professor watches it at first with curiousity but the master oblivously keeps pouring and then no longer able to restrain himself the professor speaks out "the cup is overfull. No more will go in" and then the master says "it is the same with your mind. You have filled it with prejudices and preconception, how then is it possible for me to show you zen?" Similar is the case with OOP. When we learn this style of programming, we must give up all that we had learnt in the procedural languages like C, fortran etc. OOP is a refreshingly new style of programming and requires a whole new way of thinking to be implemented. What this new way is, we shall approach shortly. Now consider the following scenario. We have the following people from a community Jerry- a team leader Kate- a negotiator, and resource manager Chirs- a software programmer Dan- a senior software consultant Mira- an accountant and steno Zoe- an automobile engineer Mike- an electronics expert Of course there are other people in the community but these are the ones who shall be in our view for the present. Excepting Zoe and Mike, all the rest make up a software firm that provides high end software solutions (including certain hardware) and of course as you might have guessed, Jerry leads the team. Now what happens is that an automobile company apporaches Jerry and asks him if they would design and program a chip that would make their latest automobile a versatile and artificially intelligent, robust beast. Of course Jerry is all too glad and consents. The company then hands over the blueprints of the car and all the design and implementation details. Jerry gets in touch with Dan and Chris and hands over the details to them. He further asks them to hire the people they will require. He then goes to Kate and asks her to meet up with Chris and Dan and get them what they need at the best price. Meanwhile Dan and Chris decide to hire (of course) Zoe and Mike (who are their friends) and call them up. The four team up and have a brainstorming session on how to go about with it. With Zoe and Mike's expert advice, Dan gets a good insight into the software and hardware requirements to resolve the problem at hand and suggests them to Chris. Now Kate comes to Dan and Chris and ask them about their requirements. The two tell Kate about Zoe, Mike and all the stuff they'll need. Kate then goes to Zoe and Mike, negotiates for a good price and hires them. She then fetches the rest of the requirements from the company's regular store. Now the four intellectuals sit together and in a months time, most of the desiging and planning is done, in another month, Mike gives the specially designed chip to the other three and leaves. His work is complete for now. The rest of them now go deeper into the intricate mapping between the software programming that needs to be done and the actual physical effect it has to have on the car. In a couple of months, the Mapping is ready and it is Zoe's turn to leave. The two are left with all they require to start programming the chip and with expert advices from Dan, Chris does a great job of it using certain detailed implementations of technologies X, Y and Z. In four months, the whole thing is ready. Now Chris and Dan sit together and make a detailed report of their product. They then call Mike and Zoe to help them complete the documentation especially things like why they chose the design/technologies they chose and about how the chip must be integrated with the automobile. And one fine day, its all ready. The whole thing is then rechecked and submitted to Jerry. Jerry then asks Kate to sit with Mira and get the whole accounts updated and get him the final bill statements. Kate does this and gives Jerry the final bill. Jerry then goes through the thing, adds in some things like development charges, consultation fees, and all those things that will actually make up for their salary. He then goes to the automobile company with the programmed chip and the documentation (which includes the manual) and submits them along with the bill. The engineers go through the whole thing, approve it and Jerry is paid. What goes on after that is more or less inconsequential to our interests here. Ok, thats the whole thing. Now I'll ask you a few questions 1. When Jerry gives the blueprints to Chris and Dan, what does he ask them to do? He asks them to design the required chip and hire the people they wanted right? Now tell me did he know what the final thing was going to be like? did he have any idea about what the guys were gonna do and give him? nopes, he just knew that all he was going to get was the "REQUIRED CHIP" and he didn't know what kind of people he was going to hire either. He just asked them to hire "REQUIRED PEOPLE" Look at that! the leader doesnt know these things, but he still gets the work done. What Jerry has done is in essence ABSTRACTION and things like "required chip" and "required people" are abstract items or quantities, for without specific information, they do not exist physically. For example- there is no chip called required chip until I specify the brand and processor speed or put down all the configurations or make it so specific that there is no amibguity about what I want. The main thing to remember about abstraction is, it gives a definition to what we are looking for- like a "dream ship" or a "perfect girl" but it never bothers to be specific because there are many things that would fit into what you are looking for and many of those would satisfy you. In the above scenario, there could have been several other chips that could suit the purpose, other than what Chris and Dan designed. In fact the main PURPOSE of abstraction is to carve out a space within which we shall go about finding solutions for the problem at hand. Let us take a deeper look into this Alan feels something is missing in his life and wants to find the solution, so he meditates upon it and realises that he needs "PEACE OF MIND" <-there we got our abstract quantity So basically, Alan figures that the problem has a solution in "PEACE OF MIND" He then writes on a piece of paper. PEACE OF MIND IS ----------FREEDOM FROM WORRY ----------FREEDOM FROM FEAR ----------FREEDOM FROM THOUGHTS ABOUT PAST ----------FREEDOM FROM NOISE ----------FREEDOM FROM DESIRE etc. Then he writes FREEDOM FROM WORRY ----------KNOWING THAT WHATEVER HAPPENS IS FOR THE BEST FREEDOM FROM FEAR ----------KNOWING THAT THERE IS SOMEONE ABOVE TO TAKE CARE FREEDOM FROM THOUGHTS ABOUT PAST ----------FORGIVING THOSE WHO MADE LIFE BAD FOR YOU and so for the others Can you see what is happening? Starting from an abstract quantity, Alan is moving to a CONCRETE solution to his problems. After two to three levels further going down, Alan catches the points in his life where things were not going according to his definition of PEACE OF MIND, and could immediately correct it. BY ABSTRACTING THE PROBLEM, THE SOLUTION COMES EASILY TO US And that is the major use of abstraction. It makes solutions come to us with ease, and more importantly in a well-defined and structured manner. And remember you can only ASK for an ABSTRACT QTY. and NEVER CREATE it. This principle we shall be using lots of times later, so keep this in mind. Now lets get back to the first scenario. Did Jerry KNOW how the thing was going to be done and that Chris and Dan had hired Mike and Zoe? Of course not, why would Chris and Dan bother Jerry (who's basically a management guy) about all the software, electronic and automobile engineering jargon? Jerry didn't need to know (period) Neither do the automobile company guys. And Zoe and Mike know nothing about how Chris and Dan programmed the chip. That is called ENCAPSULATION- or in other words HIDING DATA & IMPLEMENTATION. But why? Firstly to keep things as independent as possible and secondly to avoid unnecessary butting in. In more software like words, to preserve reusability (by making it independent) and avoid data corruption and prevent illegal actions. Consider tha fan regulator in your room. It is actually much more than that sleek knob that you see, instead it is a pretty complex circuit within and you get to see none of it. It exposes only two interfaces (here interface just means something that can interact) for manipulation. The two wires behind the board for power input and the knob for regulating output. Thats it. You don't need anything more to use it. This is a classic example of encapsulation. Imagine if the whole regulator were open, any tom would be able to tamper with it and maybe get you an electric shock or short circuit the whole power supply! Meditate on this, and you'll know why you need encapsulation. I'm reminded of an incident in my life when I had to submit a presentation at school and I was taken ill. So I had asked my dad to do it for me just so that I could escape the fury of the teachers. And my dad was kinda busy but he said he'd do it. And sometimes I'd get delirious about whether the thing got completed or not. And one day when I caught my dad, I asked him how far is it complete? and he twitched his lips and said "Why do you worry? I've told you I'll do it and I'll do it, how I do it, and when, just don't bother about these." And I set my mind at rest.and sure enough, the thing was ready on time. Another example of encapsulation, and another use- it prevents unnecessary worry, just trust things to know how to take care of themselves. The above two concepts were explained mainly as an introduction, the real thing in java, we shall when we get down to writing code. Two other concepts that are part of OOP are Inheritance and Polymorphism. These are very easy concepts to understand, the names themselves speak a good deal. We shall suffice ourselves with just an general understanding of the two, the more detailed and precise definitions we shall give later. Isn't there something common between your dad and you? or your mom and you? if yes, then you probably Inherited those features/qualities from your parent. Consider a Shape. A Rectangle is a Shape So is a Circle Let us draw an abstract to less abstract chart of Shape SHAPE (something with a boundary) ----------POLYGON -----------------TRIANGLE -----------------QUADRILATERAL ---------------------------PARALLELOGRAM -----------------------------------------RHOMBUS -----------------------------------------RECTANGLE --------------------------------------------------SQUARE -----------------PENTAGON -----------------ETC. ----------CURVED SHAPES -----------------ELLIPSE ----------------------CIRCLE --------------------etc. Can you see whats going on? A square is a rectangle and also a quadrilateral and also a polygon and also a shape. Any figure down the hierarchy is a more concrete shape- more importantly, they are all shapes. And since they are all shapes, everything that a shape has, they also have. Since a shape can be filled with color, so can any of polygon, circle etc. In other words, since these things are DERIVED from the basic BASE called SHAPE, they have ALL the properties of a shape. This is essentially INHERITANCE. INHERITANCE is when less abstract classes (called the DERIVED CLASS) of a BASE class DERIVE ALL the properties and functionality of the Base class A shape can also be rotated, therefore so can a rhombus or a triangle. But when we want to rotate a shape, we will have to do it depending on what shape it is exactly right? A circle is rotated about the axis and a rhombus around the diagonal. BUT, the BASIC OPERATION is ROTATE, and rotate is what we shall do. But again, it DEPENDS on what exact shape it is. Therefore a circle has a different WAY to ROTATE and so does a rhombus. When different derived classes behave differntly when the same operation is performed, it is called POLYMORPHISM- i.e it is morphing (changing) in many ways (poly). We shall stop with a funny kind of polymorphism but this is just for fun, the accurate version is the one above. Every morning I go out for a walk and it happens that I come across quite a few people I know. What happens when you come across people you know? they probably greet you- now this is the way each of them greet me. Uncle- hello sonny, how're you doing Girlfriend- Heyyy (with a lil honey in her voice, and a wink) whats up dude Friend- whats up buddy, whats your plan for today? Close friend- Whats up *#$%& ( with a whack on the back - no offence intended) Angry Classmate- (venom in his eyes) grrrr The Colony Grouch- -sNoRt- Well, they're all people, but because they're all different, they do the same thing (greet) in different ways. Thats polymorphism too! Thats all for today, Tomorrow, Thinking in Objects and Java language basics. Have a great day, and watch that softnote in your voice when you meet that special person polymorphic man.
  3. For further information, 1 calorie is equivalent to 4.18 joulesJoule is the Standard International unit of work and in other words is the amount of work done to lift and object of mass 1 kg to a height 1 metre on the earth's surface. for those of you interested in nutrition or are calorie conscious, check out the calorie calculator at this site http://www.stevenscreek.com/goodies/calories.shtml
  4. Does it seem like a small bone protruding? with a slightly sharp edge? and is it located near your earlobe?if thats the case, there nothing to worry, its just the swelling of a gland and will subside.Taking hot coffee and other hot drinks will considerably reduce the pain and the swelling. It is however best to consult a doctor, in any case your fears are baseless, it need hardly be cancer, the doc might advice you a couple of antibiotics nothing more.cheer up and have a great day.
  5. Google returns a million hits to a query my friend. A forum facilitates intelligent information sharing. It relies on the insights and experiences of the contributors where as google just returns mechanically. So which would you prefer? And anyway google can never return 100% relevant answers!
  6. If you are on a Unix system try this out: At command prompt type: cal 9 1752 Thats the calendar for september 1752 and this is what appears September 1752 S M Tu W Th F S 12 13 14 15 1617 18 19 20 21 22 2324 25 26 27 28 29 30 Isn't the output queer? A month with whole eleven days less? This was the time England shifted from the Roman Julian Calendar to the Gregorian Calendar, and the king of England ordered those 11 days to be wiped off the face of the month of September of 1752. (What couldn't a King do in those days?!) And yes, the workers worked for 11 days less, but got paid for the entire 30 days. And that's how "Paid Leave" was born. Hail the King!
  7. The Java Programming Manual Chapter 0: Introduction. What Java is and what it is not Java is an object oriented programming language that has evolved from and to substitute the C and C++ programming languages. But why? The main reason for Java to have evolved is "platform independence" we shall come to this part later. When a programming language is designed, certain trade offs have to be made. 1) Ease of use versus Power 2) Efficiency versus Safety 3) Rigidity versus Extensibility This also gives a more or less accurate comparison of C++ versus Java Java has chosen all the latter parts of the trade offs- in other words, it is Powerful, Safe and highly Extensible. Does it mean that Java is difficult? Hardly. Once you get the hang of it, no programming language is more difficult than the other. Is Java Inefficient. This is difficult to answer. Immediately it might seem that java is slightly inefficient, especially in the smaller applications. Where C and C++ take seconds to get results, Java seems to be taking ages. But then, to gain something, something else has to be lost. However for scalable applications especially those designed for the web, with good performance tuning, Java can easily displace C++ as an alternative. What is all this commotion about safety? Well how would it be if anybody would be able to enter your house and get away with whatever you liked? Eat your favorite apple pie and leave the remains for you to weep about? Thats just the way it is here. Java is very particular about what belongs to whom and how much permission anybody else has to your property. You, the programmer get to decide and restrict the access of every object. Why not C++? Well, C++ is notorious for two of its virally pervasive programming problems. 1) Memory Leak: This occurs when an application dynamically allocates storage and does not bother to free it. This thing is very easily overlooked by programmers and they end up clogging the memory and getting the system to a hangover. 2)Deadly Diamond Deadlock: This is another trauma of object oriented programming. We shall explain this after we have discussed the concepts of object oriented programming. So what does Java do about these? Not so fast. Let us just know that java overcomes these, and don't tempt yourself into finding out the answers immediately, allow me to preserve the suspense so that at the time of revelation, it will come as a beautiful surprise. When the time is ripe, everything will be answered. Whats so great about Java? If its edge over C++ hasn't sufficiently impressed you, java has become synonymous with the world wide web. Why? Everybody seems to have a computer but does everyone have the same operating system? of course not, and that is where java comes in with its revolutionary "WRITE ONCE, RUN ANYWHERE" technology, so anyone with a java virtual machine (which is available free of cost from http://www.oracle.com/technetwork/java/index.html and is very small size-wise) can run your module and see it more or less just as you did (didn't we talk about platform independence?) Anyway, here are a few Buzzwords that java attracts Simple Secure Portable Object-oriented Robust Multithreaded High-performance Distributed Dynamic (you can see what the creators had in mind here http://www.oracle.com/technetwork/java/index.html ) None of these would make much sense without a context and without a problem, so tell you what, let us get on with the language, and as and when the context arises, I shall pose the problem and give you insights on each of these. And Please, Java is not enhanced html. Html is a markup language- meaning it is just a way of presentation, java on the other hand is a full fledged programming language, with extremely powereful features especially networking capabilities. In the process of learning you shall really appreciate the power of java. I have tried to make further reading a fun and enjoyable experience without trading off on the serious side of programming. This manual is intended as a step by step guide for the basic and advanced users and will build and strengthen the fundamentals of the languae and go one step ahead to unleash the power of the language. Suggested Books Java complete reference- Herb Shuldt Head first java- Sierra & Bates Java, how to program- Deitel & Deitel Core Java- sun microsystems press. Thinking in java- Bruce Eckel The next tutorial will teach you how to setup the java software development kit and other related topics so that you can be ready to start programming OpaQue : CHANGED THE FONT : It was hurting.. Chapter 1 Setting up your system for java software development. Step 1: Get the Java software development kit Download the latest version of J2SDK (Java 2 Software Development Kit) Version 1.5.0 update 4 (suitable for your operating system) from the website http://www.oracle.com/technetwork/java/index.html or get it from a CD especially those that come free with your computer magazine or with a Java text. Note: You need to get the Java SDK and not the Java Runtime Environment (JRE). The JRE is bundled within the SDK so don't worry about that. And another thing. Download the corresponding API specification docs ( in zip format) from the same site. This is an indispensible reference guide to your whole software development. This is avaible only on the sun site and will most probably not be packaged with the J2SDK on any free distribution CD. Step 2: Installing the SDK and Configuring your PC for the development. In this course I shall be using the SDK on a windows machine and therefore all the configuring is described for a windows machine only. A linux/mac os user should have enough information to do it himself. In any case, the whole produre is properly described in the Installation notes section of the Readme when you install the SDK. Firstly run the sdk installation file and ask the program to install the into the folder c:\j2sdk5.0 or d:\j2sdk5.0 or whichever drive you wish to install it. It is better if you install it in the first level itself. For example installing it in c:\xyz\j2sdk5.0 etc will cause certain inconveniences at a later point of time. Let us assume we have installed it into the c:\j2sdk5.0 directory. Now look into the directory and you'll see folders like bin <- this is where the compiler, and other utilities are stored demo <- you will find some demo goodies here include <- the native library files jre <- the runtime environment is here lib <- the java library files and files like readme.htm <- read this for everything you need to know about using the sdk readme.txt <- a text version of the same src.zip <- this is where all the source files are kept, or "classes" as they are called in java ( The bricks of a java program.) Unzip the contents to a folder called src in your j2sdk5.0 folder. We will need to take a peek into this sometime later. and other files. Another thing you must do is unzip the API specification document's zip file into a folder docs in the j2sdk5.0 folder. Now that we are done with the installation, we shall configure the pc. Open the command prompt and type the following EXACTLY we shall denote the command prompt as $ (omit typing this at the prompt) $SET PATH=%PATH%;C:\j2sdk5.0\bin; This tells the OS to look for executables in the directory c:\j2sdk\bin and now $SET CLASSPATH=%CLASSPATH%;c:\j2sdk5.0\lib;.; And this tells the OS to look for classfiles in the lib directory and also the current directory which is "." . This step is called Setting the Classpath and the above, as is obvious is called Setting the path. Restart the computer or atleast the DOS for these changes to take effect. Getting yourself some text editors. During the stage of development I suggest the we use the "EditPlus" text editor which is a good environment to write code, not fanciful, fast and free to use. You can download it from the editplus site. It is suggested not to use Integrated Development Environments (IDEs) like NetBeans or SunOne Studio, they make complex things easy and easy things complex and guzzle on your system resources. Another text editor is the textpad available at textpad.com You can if you feel comfortable use the edit utility of DOS, but its a bit too stark with no mouse navigation or GUI. I shall use the editplus text editor in all the further coding we are going to do. So now we're done, ready to start coding, but before that we shall get acquainted with concepts of object oriented programming for we will be referring to most of the OOP jargon in the rest of the tutorials. So tomorrow, an introduction to OOP. Have a nice day!
  8. Doomsday algorithm The Doomsday algorithm is a way of calculating the day of the week of a given date. It is perpetually accurate since the Gregorian calendar moves in cycles of 400 years. It makes use of the fact that, in each year, certain dates are all on the same day of the week. The algorithm was invented by John Horton Conway. It can be used for either the Gregorian Calendar or the Julian Calendar, but note that Julian calendar Doomsdays usually occur on different days from the Gregorian calendar Doomsdays. The algorithm The algorithm has three steps, namely, finding the anchor day for the century, finding a year's doomsday, and finding the day of week of the day in question. To find a century's anchor day, begin by finding the century which the date falls in. (For the purposes of this calculation, century years will be treated as though they fall in the century that follows, even though they technically fall in the same century as the years before them. 2000 is therefore part of the twenty-first century, not the twentieth century.) A year's century number is equal to its first two digits plus one (so 1966 is in the twentieth century). Take the century number and multiply by 5. Separately, take the integral part of the quotient when the century number minus one is divided by four. Add these two numbers (the product of the multiplication and the integral of the division). Taking the remainder mod 7 is often done at this point to make the numbers more manageable, since it won't affect the result. Now count forward that number of days from Thursday to get the anchor day for the century. For example, the calculation for the twentieth century is: multiply the century number 20 by 5 to get 100; subtract 1 from the century number and then divide by 4 to get 4; sum 100 and 4 to get 104; find the remainder mod 7 to get 6; count 6 days on from Thursday for the answer, Wednesday. Similarly, the anchor date for the twenty-first century is Tuesday. Next, one must find the year's Doomsday. To accomplish that according to Conway, begin by taking the integral part of the quotient when the year's last two digits are divided by 12. Next, determine the remainder of this first quotient. After that, take the integral part of this number when it is divided by 4. Finally, determine the sum of the three numbers. (This is equivalent mod 7, as it must be, to the sum of the last two digits plus those digits divided by four.) Now count forward the specified number of days from the anchor day (again taking remainder mod 7 can be done) to get the year's Doomsday. The following days all occur on Doomsday for any given Gregorian year: January 31 (or "January 32", ie February 1, in leap years) February 28 (or February 29 if it's a leap year) "March 0" (a backwards extension of the calendar, equivalent to the last day of February.) April 4 May 9 June 6 July 11 August 8 September 5 October 10 November 7 December 12 The dates listed above were chosen to be easy to remember; the ones for even months are simply doubles, 4/4, 6/6, 8/8, 10/10, and 12/12. Four of the odd month dates (5/9, 9/5, 7/11, and 11/7) are based on the phrase "I work from 9 to 5 at the 7-11." The following is the algorithm in C. Please note that division in C (using the / operator) is integer division and that the % operator is the modulo operator. Set "year" to whatever year (this case is 2005) computation is desired and the numeric values of the days of the week are: 0 â Sunday 1 â Monday 2 â Tuesday 3 â Wednesday 4 â Thursday 5 â Friday 6 â Saturday // Determine the anchor day for the century year = 2005; century = year/100 + 1; a = century * 5; b = (century - 1) / 4; c = a + b; anchor = (c + 4) % 7; // Determine the Doomsday for the year in question e = (year % 100)/12; f = (year % 100)%12; g = f/4; h = e + f + g; dday = (h + anchor) % 7; "anchor" is the anchor day for the century and "dday" is the doomsday for the year. If "dday" is found to be Monday, then January 3 (or 4th), February 28 (or 29th), March 0, April 4, May 9, etc. (see above). To find the day of the date in question, determine the number of days away from the doomsday for that month and add it to "dday" modulo 7. This article has been taken from the wikipedia and is free under the gnu documentation license. If the forum doesn't allow such "knowledge sharing" kindly let me know. have fun calculating the day of the week for any date. I will in near future put up a complete working code in java to do the same. more useful information is also available at http://quasar.as.utexas.edu/BillInfo/doomsday.html
  9. I had been lately looking to find some text formatting tools, especially to convert the gutenberg etexts into printable matter, the major problem was the word wrap, that caused the a line return to be inserted after 'n' columns. for example "hello I am so and so from so and so.com please welcome our guest so and so who is a so and so blah blah blah. this is to inform you that so and so also has a so and so blah blah blah" would appear as "hello I am so and so from so and so.com please welcome our guest so and so who is a so and so blah blah blah. this is to inform you that so and so also has a so and so blah blah blah" and make it an almost impossible task to go around deleting all the '\n' characters. so I looked and looked till I found this real cool page with heaps of great text formatting utilities for windows/dos http://forums.xisto.com/no_longer_exists/ I used the one near the end called "remove", they're all free to download and use. And extremely small in size! Have a great day!
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.