The Way to Programming
The Way to Programming
#define maxdim 10 typedef float TRealMatrica[maxdim][maxdim]; . . . TRealMatrica A,B; . . . void ProizvodMatrica(float (*A)[maxdim],float (*B)[maxdim],int NA,int NB) { TRealMatrica P; int i,j,k; clrscr(); if(NA != NB) { printf("\nERROR: Rows must be same!"); } else { for(i=0;i
I am assuming that your question is how to read from the shared memory concurrently, without worrying about the data being corrupt by a writing process. First of all, you need some sort of locking mechanism. In the case of multiple processes trying to access a piece of data simultaneously, I do so through a monitor.
http://en.wikipedia.org/wiki/Monitor_(synchronization)
The monitor will basically ensure that you can have many simultaneous readers, but writers have exclusive access to a specific datum. I hope this answers the question.
First, you might want to check out the proper MySQL syntax. Secondly, I hope you’re doing some security with $myusername. Thirdly, variables in single quotation marks (”) won’t be parsed. Finally, I’d do some MySQLi research.
Bug #1
Do not cast a double to an integer. If your goal is to use an integer, you must convert the frame time to the unit you want (microseconds, milliseconds, etc.) and then update your numbers to reflect this change.
Bug #2
When the ball hits the bottom/top of the paddle and the lower/upper bounds, it doesn’t give a score, it just tries to go the other direction. Since it’s processing the collision twice, it will get stuck. The ball can also get stuck on the paddle if it hits the top or bottom of the paddle. Since the x direction changes and if the paddle goes fast enough, it can cause a collision to be detected. One fix can be moving the region for scoring and hit detection.
Bug #3
That will give you the range if you don’t put max where min is suppose to be (ex. 8 + (rand() % (5 – 8 + 1)). You’ll have to explain what you actually want to accomplish if it doesn’t “work” for you.
Bug #4
I can think of a few things
1. Predict where the ball will go. The problem with this is that the AI will never lose. To fix this, you’ll have to introduce difficulty and base the accuracy on that.
2. Don’t move unless you have to. If the ball is slow, there will still be a jitter, but it wouldn’t be as bad. You can make it better by giving a range of when to move in the x direction.
3. Make the ball faster than the paddle.
well, this is quite simple to explain :
in this section :
function mytheme_add_admin() { global $themename, $shortname, $options; if ( isset($_GET['page']) && $_GET['page'] == basename(__FILE__) ) { if ( 'save' == ( isset($_REQUEST['action'] ) && $_REQUEST['action'] ) ) { foreach ($options as $value) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } foreach ($options as $value) { if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ] ); } else { delete_option( $value['id'] ); } } header("Location: admin.php?page=functions.php&saved=true"); header("Location: themes.php?page=functions.php&saved=true"); die; } else if ( 'reset' == ( isset($_REQUEST['action'] ) && $_REQUEST['action'] ) ) { foreach ($options as $value) { delete_option( $value['id'] ); } header("Location: admin.php?page=functions.php&reset=true"); header("Location: themes.php?page=functions.php&reset=true"); die; } } add_theme_page($themename, $themename, 'administrator', basename(__FILE__), 'mytheme_admin'); }
you have a header() function , which is being called at some point in the script , the problem here is :
a header has already been sent, hence the warning …
If you want to clear the errors, either suppress them , or move the code to the top of the php file BEFORE any output is generated
The NeXT Computer was based on the new 25 MHz Motorola 68030 central processing unit (CPU).
The Motorola 88000 RISC chip was originally considered, but was not available in sufficient quantities.
It included between 8 and 64 MB of random access memory (RAM), a 256 MB magneto-optical (MO) drive, a 40 MB (swap-only), 330 MB, or 660 MB hard drive, 10Base-2 Ethernet, NuBus and a
17-inch MegaPixel grayscale display measuring 1120 by 832 pixels.
In 1989, a typical PC included 640 KB to 4 MB of RAM, the 8086, 8088, 286 or 386 CPU,
a 640×350 16-color or 720×348 monochrome display, a 10 to 20 megabyte hard drive and few networking capabilities.
To this day it remains a mystery how Bill Gates was able to brute force all of the Lemmings to believe the ‘hype’ that he was creating great OS software. Cleary, in this case, Elegance lost out to inconsistent poorly designed software.
Take a look at Object Oriented Programming and study data representation and data abstraction. These concepts are invaluable for real world problem solving.
To review, there is more than one way to code a solution. You can have an elegant solution that works and has many safe guards for catching errors and features that make the application easy to use for the intended user or a program (like many Microsoft Programs) that are prone to errors, makes the user click endlessly on superfluous non essential things and crashes frequently.
I am a person that develops using the RAD (Rapid Application Development) approach for most of my projects.
I did away with the traditional Systems Analysis approach taught in College (and I might add, that I, myself taught for 9 semesters many years ago) in favor of the quick and responsive. I used to make mock up screens, and charts and reports and other “aids” to demonstrate what the proposed new functionality was going to look like. Now, my ‘mock ups’ are functional.
If I have already created a working concept of a form that captures 6 pieces of information, it’s easy to go in and add the 7th piece that we find is necessary a month later. On the project I am working on now one database form started with 5 pieces of information, it now captures more than 20 and while it is evolving with other development going on it is a fully functional entity that is constantly being tested at the same time.
Only the largest of companies and products being developed have the money for the traditional approach.
In today’s fast paced “We need this two weeks ago” world, RAD gives people a visual, hands on, almost immediate feedback to the current project. Clients can then say “We like – we don’t like” right off from the get go. By the time the system is done they are already familiar with it and already “trained” because as part of the on going development process they are already “experts” in using it.
So, my long and drawn out point is that fast coding / learning is great for real world applications but it must be tempered with good coding practices help the “student” develop their own sense of coding style for creating well designed, sturdy programs.
And coding style is something a person develops over many years after millions of lines of code have been written.
The hardest thing in the development world is to modify someone else’s code; especially if the code was not designed eloquently.
Some times you can look at someone else’s code and it is like walking outside on a lovely Spring day. The code is brilliant, clear, easy to understand and modify; you say to yourself: this is exactly how I would have done it.
Then, there are times when you look at code and your brain starts to hemorrhage or melt. You’d rather be anywhere on the planet (including prison) than where you are sitting.
Be thankful that you don’t ever have to wade through the gobbledygook from Microsoft’s old BASICA with all of the completely horrid GOTO’s that most people used back then.
That being said, if you do eventually get into this business and you improve, you can’t be promoted into management or into team lead positions if you write obtuse code that no one but you can understand. You have to be able to train the people under you to take your spot.
All programs written in high level languages, no matter how grandiose, will ultimately revert to the smallest common denominator and that is the Assembler Language of the computer architecture of the machine you are running on.
I used to love to program in Assembler. The only language that has the same level of power to go skip, dancing naked in the computer forest is C with its inline Assembler capabilities.
To learn, you need something simple and visual basic, in my opinion will allow you to at least get a feel for what’s going on.
Write as many practice programs as you can. After you have coded a solution see if you can write the program in a different way; perhaps more efficiently or using a different approach.
Soon, you will get the hang of it and start to develop your own sense of style.
Practice, Practice, Practice!
AND HAVE FUN!
Right now, you need not concern yourself with trying to write Production Code or the Newest Sensational Game. What you need to focus on is problem solving.
Here is an EXCELLENT COURSE (which uses Python as the teaching language) that is offered by MIT. This series of lectures teaches you HOW TO SOLVE PROBLEMS and then match those solutions to code.
http://www.youtube.com/watch?v=bX3jvD7XFPs
Once you learn one language very well it becomes easier to migrate to other Computer Languages. After your 6th language, it become a matter of “how do I say “Salary equals HourlyRate times Time Worked” in this new language I am learning?
The languages I’d recommend to beginners would be C# for Windows applications and PHP for web applications.
PHP was a good recommendation, but C# was not. C# is completely object oriented and it can be overwhelming for a beginner. So I say you stick to PHP and learn its object oriented side too (which is a fairly advanced PHP concept), so you’ll have a better understanding when moving to complete object oriented programming languages such as C#, Java, C++ etc.
I strongly suggest you to switch linux environment. Dont ask why ask google.
I don’t see this being relevant to this topic, but Linux wont make you a better programmer. It depends on the platform in some cases, like if you want to make Mac/iPhone applications, you have to use a Mac. But in general programming, all operating systems are equal, all having advantages and disadvantages.
This should be pretty simple to create. What programming language are you using?
I’ll see if I can write it up using C# quickly to give you an idea.
In a very basic way :
In your CSS sheet place the id “comments” on the bottom , within comments.php you can extract from your SQL db the comments or have them added , whatever you wish…
You could use
http://www.learnjavaonline.org/
or, more fun, follow the tutorials on Greenfoot
http://www.greenfoot.org/
Well i don’t know any thing about coding but IT field is not only coding websites etc there are lot of other fields in IT. like Hardware, Networking, Virtualization etc. you can try one of these fields. if you are good in any one of these fields your salary starts from 50k to 70 k depending on where your live. in these fields you need understanding how things works you don’t need to have programming skills. people in these fields make more than 200K depends on who you works for and where did you work. but finally its upto you what you like and you want to be future.
Good luck with your future
You do sound a bit full of yourself “I was very good”, “as I’m building it”. No disrespect but even your previous programming knowledge goes out the window with stuff like js/php as they are very complicated languages. (Well, as complicated as you make it to be). Learning php will take a while and is not something you simply learn in a day. Your best bet is to try building the intranet now and google the problems as you come across them. You may want to find out how to store persistent data across page loads (MySQL with insert and select statements).
I’d personally let them go with the most reliable option. Simply put if you don’t know the langauges that you will need to use well enough today, you won’t in another month, or three, or six. Don’t try to impress them based on stuff you don’t know.
i did the code with a friends assistance….but i haven’t completely understood it.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace onef { public struct onef { public int studentid; public string studentname; public string coursename; public int dob; public void get() { Console.WriteLine("Enter Student ID:"); studentid = int.Parse(Console.ReadLine()); Console.WriteLine("Enter Student Name:"); studentname = Console.ReadLine(); Console.WriteLine("Enter Course Name:"); coursename = Console.ReadLine(); Console.WriteLine("Enter Date of Birth:"); dob = int.Parse(Console.ReadLine()); } public void display() { Console.WriteLine("ID >> " + studentid); Console.WriteLine("Name >> " + studentname); Console.WriteLine("Course >> " + coursename); Console.WriteLine("DOB >> " + dob); } }; public class program { public static void Main(string[] args) { onef[] obj = new onef[10]; int i; for (i = 0; i < 10; i++) { obj[i].get(); obj[i].display(); } } } }
Well one way to do so would be something like:
//This depends on what you want to select of course. $sql = 'SELECT number_of_items FROM '.DB_PREFIX.'item_blocks WHERE id = IN(1, 2, 3, 4, 6, 9)'; $res = $db->query($sql, array($i)); while($row = $res->fetchRow()) { //Do something with your data }
With MySQL’s IN() function, you can pass a number of (in your case) ID’s, which will all be fetched. I think this is the best solution for you.
Learning how or where to program is not an easy question to answer.
Programming is a discipline that combines Art (elegant solutions) and Science (Math, logic, procedures) into an envelope that represents your style.
Many, many years ago (60’s, 70’s and 80’s) most applications were single language programs. You would do the traditional Systems Analysis complete with reports and spending justifications and then (skipping many steps) you wrote C, Pascal, Fortran, COBOL, Lisp or some other language, compiled and linked it to an executable on some hardware platform and you had a working program/system which you then debugged and handed over to some client (again skipping many steps) to use.
In todays world, things are in many places, they exist in cyberspace or cloud, on local machines, etc. Systems today can contain many different languages combined. For example: years ago I created an Access Database (VBA Script) that sends data to a Server in cyberspace that that I wrote using PHP that then loaded the uploaded information into a MySQL database which was the data storage for a website that was written in PHP and used also used Java Script.
That’s just one example. The possibilities are endless.
But the Devil is not in the details or procedures.
You can’t program in any language if you can’t solve problems; if you can’t break apart a known problem down to the individual components necessary to create the algorithmic solution to solve or perform the task.
I found a series of videos on YouTube from MIT that does just this. If you watch these videos and do the assignments (in Python) you will learn a) how to create solutions to problems and b) learn a new language if you already don’t have Python under your belt.
http://www.youtube.com/watch?v=bX3jvD7XFPs
Once you truly understand the concept of problem solving then the world is your oyster! You can write your own ticket. Then it’s a matter of preference as to what area you decide to work in.
For me, I hate anything that has anything to do with .NET but that’s me. I love PHP, Objective C used to be a favorite in the 90’s when I was programming on NeXT computers using the NeXTSTEP Operating System, and other development environments. I actually enjoy (to a limited degree) working with VBA and Microsoft Access Databases. It’s a much nicer development environment than Visual Studio or .NET (at least for me because even though I use Access I’m not really a fan at all of Microsoft.) and I have enjoyed working on other things as well.
For me I’m about as tired of programming as a person can be. I’ve been doing it since the late 70’s and I’ve worked on some cool things. I saw the birth of the World Wide Web in November, 1991; I’ve played on Cray computers and was part of a project where we piped a 15 minute video created by Steven Spielberg and George Lucas over 30,000 miles of fiber optic cable using an ATM network. These were among the first video transmissions (stuff we take for granted today) over fiber optic networks in the early 90’s and all kinds of other really cool projects.
There was a time when I couldn’t wait to get on a computer and do some coding! I would wake up at 3:30 AM with a solution to a problem and go into work to code it. This was before it was common place to operate a computer remotely.
Now, cooking is my new passion, or revived passion. I’ve always loved to cook.
Good luck and happy programming.
Sign in to your account