pandu Posted December 16, 2010 Share Posted December 16, 2010 Hello, New to PHP and have so far been able to make some good progress on learning to code. However, I get stuck when converting an idea into code. I recently built this simple web app called ezsynonym.com. It simply queries a table of words and then results the relevant synonyms. Now I want to add more features such as 1. allowing users to rate the synonym results and 2. allowing users to submit better synonyms. But I am drawing a blank on going from above requirements to coding. What do developers do when they come across requirements? How do you break down a requirement into design, into algorithm, database structure, ec. TIA Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/ Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 Developers usually know what methods they can use to reach an end. Allowing users to rate synonyms is simply a matter of having a button/icon/link for rating. That then sends a request to the server which will +1 vote for that synonym. You then have the issue of designing the database to facilitate such a thing. Some people will use a counter and increment of every vote. The better solution is to use a new table (say 'votes'). Each new vote will create a new row, rows use a foreign key which relates them to a synonym. Allowing users to submit synonyms is - on the frontend - a html form, submit to server, check no duplicates exist in database, insert new synonym if not. I can see I have basically only elaborated on your idea but if you can't turn the above into code (like ANY code) then you should first buy a book on how to code php and mysql. I would also be surprised how you created what you already have if you can't do the above. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1147924 Share on other sites More sharing options...
pandu Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks anti-moronic. Once I get some guidance on how to approach a problem, I am able to code it up. But its going from idea to some sort of design plan, that I get stuck at. Perhaps, its just one of those things that comes with experience? I would like to hear more ideas and suggestions on how you guys come up with a design/architecture - not just for the requirements I mentioned above but for any of your own projects. TIA Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1147925 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 Something which will likely help you a lot regarding application design: http://www.macronimous.com/resources/web_development_life_cycle.asp http://dev.mysql.com/tech-resources/articles/intro-to-normalization.html http://php.net/manual/en/language.oop5.php Those 3 links will definitely help you understand a little more. I mean application design can get VERY complex so you're better off searching for tutorials or books. For me, I first determine if it is viable to use a framework (which is almost always is). If so, then I use Zend Framework which relies heavily on OOP and principles. This means half my application will already be built because I already have most of the components required, so it is then a matter of adding application specific code. However, long before this you need to clearly define your database design. 'normalisation' is key. I had a project a while back where I failed to realize that one table should have been split up into two for abstraction purposes. Later on I was required to make changes which demanded this normalisation and with it a whole bunch of changes to my application. Changing the data structure half way through or after an app has been built is not my idea of fun. Once you have your database down, then you might move onto some basic frontend and backend code. A kind of 'prototype' where you may or may not use this code in the final app. You are simply doing this for testing purposes. Note: this is specifically for you. With more specs, I would first define a full feature set. After you are happy with your tests you begin to build your actual application. Big projects will definitely benefit from thorough application design prior to this. For something small like what you have it isn't required. All you need to know is that OOP is the way to go. Using frameworks is highly beneficial. Try the Zend Framework for example. It will teach you how to use OOP effectively. During development depends entirely on preference. Some people do TDD (test driven development), I take a more 'continuous integration' approach. http://en.wikipedia.org/wiki/Continuous_integration I hope this gives you a little overview of what might go into the design process. This is by no means exhaustive. Entire books have been written on the subject. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1147959 Share on other sites More sharing options...
QuickOldCar Posted December 16, 2010 Share Posted December 16, 2010 I agree with what Anti-Moronic said. Additionally you should create a structure that could easily be added upon or edited for the future. Organization is your friend. Make yourself an include folder for any included files like functions, have a cache folder, an images folder, make it so that when need to find something you have a pretty good idea where to look for it. Such as your votes as a for instance, you can add to the code directly to your pages or include a folder or file of this code to be used, then reference to it from the visible page. I feel the most important thing would be flexibility. Mostly thought is required of what you need to get accomplished for the task at hand. There is many instances where there may not be an answer and must be creative, or is multiple ways to get the task done. Many times is trial and error for the most reliable, fastest results, least server usage, adaptable and any other requirements of running a specific website. So you have your basic website built and platform, now just keep adding additional features that you would like it to have. Test the site often for the changes you make so you don't end up having many errors at the end and having a complete mess. I would even suggest having a backup folder of your codes so can always revert back. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1147975 Share on other sites More sharing options...
QuickOldCar Posted December 16, 2010 Share Posted December 16, 2010 Well since this seems like an interesting topic to me I'll write some more. For my dynaindex, I had to give it 2 years of thought in my head before one line of code was written. It took me that long to come up with something I thought could possibly work. I had the idea, I wanted to do it, so attempted in a variety of ways and came to the conclusion of which way was the best way in the long run. Then sitting down and in 3 months with much frustration and hurdles, I finally got something acceptable to me, and progressed with that. I decided to make my own cms/platform so I had more control over it, if there was to be an error somewhere, it was my error and I should be able to find and fix it. For the past 9 months as I use and add features to the site, if I see something I don't like, I make a rule for that squished in somewhere between the rest of my code, sometimes completely rewrite the entire function or process. Other times if is a specific function, then a complete new folder which would include text files and a few separate php files. Basically after all I said above, have the idea, think of a few ways could possibly do it, then attempt to write some code that does it. If those codes don't work the way you want, try a different way you think of. That's the beauty of php. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148004 Share on other sites More sharing options...
laffin Posted December 16, 2010 Share Posted December 16, 2010 I have to agree with anti-moronic. When it comes to implementing an idea into code: 1) Data design/storage 2) codeflow design 3) implementation if you don't have #1 done, you will find that #2/#3 become very difficult. if u need tools to help you with the design, use a diagram editor to visualize how your db/app design should be like. Dia Diagram Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148038 Share on other sites More sharing options...
trq Posted December 16, 2010 Share Posted December 16, 2010 Some people do TDD (test driven development), I take a more 'continuous integration' approach. Of course, CI can be (and normally is) used as part of TDD. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148063 Share on other sites More sharing options...
pandu Posted December 16, 2010 Author Share Posted December 16, 2010 Hello, This is a repost of a thread that I posted earlier (http://www.phpfreaks.com/forums/php-coding-help/advice-on-how-to-convert-idea-to-code/new/?topicseen#new). I wanted to get more feedback and so am posting again. I am seeking advice on what is the best way to go from idea to code. I know there is an intermediate step where a developer figures out the design (not graphics design but the architecture), the database structure, the algorithm, etc. I read somewhere that the best way to go from idea to code is to draw a flowchart. But flowchart does not seem to be good for object-oriented programming (which I am getting familiar with at the moment). Somewhere I also read that for every requirement, start by creating a table and then refine. Are there other design techniques? I would appreciate all ideas and links on this matter. TIA Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148193 Share on other sites More sharing options...
BlueSkyIS Posted December 16, 2010 Share Posted December 16, 2010 flowchart is fine for oop. the logic doesn't change. for my projects, i typically start by database design, then start coding. requirements will change, other things will change. i don't spend time drawing pictures, i just do it. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148206 Share on other sites More sharing options...
pandu Posted December 16, 2010 Author Share Posted December 16, 2010 Thanks BlueSkyIS. What is your approach to the database design? Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148215 Share on other sites More sharing options...
BlueSkyIS Posted December 16, 2010 Share Posted December 16, 2010 think about it, build it, keep it normalized, modify as needed. when i worked in the corporate environment, building major multi-faceted systems for large utilities and municipal governments, it made sense to spend time drawing things and writing stuff down before the developers even got to see it. but if i'm the developer building a simple website on a limited budget, i don't waste the time drawing and writing down the obvious. i do a lot of projects budgeted at under $500, so i need to get the ball rolling as quickly as possible. i find it much more intuitive to 'get my hands' dirty instead of drawing a picture or writing stuff down. but that's me. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148220 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 Some people do TDD (test driven development), I take a more 'continuous integration' approach. Of course, CI can be (and normally is) used as part of TDD. Ahh, yeh, of course. My intent was to illustrate the separation of what I note as 2 common development paradigms: one being TDD, where you would build unit tests and *then* build actual app code based on those, and the other where you would build actual application code from the beginning and continuously test that code at certain points (like after each feature, module etc). I'm not sure CI would be the right term in that regard. To be quite honest I've never done much TDD. I'm in the crowd who believes it's somewhat a waste of time in most scenarios. However, I will definitely be utilizing automatic unit testing shortly due to management of some large codebases, though the unit tests would be created after completion as a kind of intergration testing for further developments. To OP, forgot to mention, there are several tools you might find useful: http://wb.mysql.com/ (for database design and a central location for db management) http://www.xdebug.org/ (for debugging and profiling code) AND http://sourceforge.net/projects/wincachegrind/ (for reading cachegrind files) http://jakarta.apache.org/jmeter/ (for further performance testing) In fact, if a mod reads this, is there any chance of somebody creating a thread to include these tools or other tools? We have one for IDE's and such but I think the above can really change how you develop code. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148238 Share on other sites More sharing options...
Elridan Posted December 16, 2010 Share Posted December 16, 2010 if you are working on a larger project, such as one where you figure out the databse beforehand, how do you decide what you need in the database? I'm working on my first PHP project and I've made alot of progress on it (to me anyways) having never used php or mysql before, but I've had to start with a basic mysql database and table and work my way from there. I didn't know what I would need beforehand so I just kept adding things and revising things as needed until I got to where I am now (which is probably very near to it's final design). Is this something that just starts coming to you as you work with more and more databases? Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148248 Share on other sites More sharing options...
laffin Posted December 16, 2010 Share Posted December 16, 2010 About only tool you don't mentiion is a decent text editor Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148265 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 BlueSkyIS makes an important point. The depth you take your application design to does depend on project size. If a project is budgeted at under $500 then I would think it is quite small and doesn't warrant flowcharts and such which might go into a project worth $2000+ But, to note, this isn't based on budget; it's based on project size. If you take on a project under budget which really should go through a thorough design process it's your fault if problems come up later due to lack of design because you didn't charge enough. ..and this can change entirely if you're working with a team; you can't afford NOT to go through a standard design process otherwise your team will have trouble coordinating. Everybody needs to see the same picture and as you know, different people view things differently in their head. Flowcharts cannot conflict with OOP. A flowchart can represent anything - an application in general, a module, a library, class. @elridan, proper database design comes with knowledge, not experience. It's the knowledge of HOW a database should be designed, what things should be taken into account and how that can affect the structure. Main thing with database design is normalisation, which is a way of abstracting the structure so to speak. Almost everything else can be ironed out later, but changes to the structure can have massive impacts on your application. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148276 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 About only tool you don't mentiion is a decent text editor Yup, mainly because I was trying to think of *other* tools, so to speak, which help in development. On text editors - can't go wrong with notepad++ though I did move onto Zend Studio (mainly for it's integration with ZF). I've heard mac has some really good text editors (textmate?). Not sure what other editors offer code completion and template code, off the bat (for php), but I gotta say ZS is absolutely priceless is this department. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148277 Share on other sites More sharing options...
laffin Posted December 16, 2010 Share Posted December 16, 2010 But a tool is only as good as the operator. if you don't have any exposure to a tool, (Flowcharting, OOP, PHP, Hand Drill, Car) that tool to you is useless. So even if we provide you with a list of the tools we find helpful, the only way to use those tools effectively is by using them and learning them. But flowchart does not seem to be good for object-oriented programming A Flowchart can about represent anything, its an overview. A Visualization tool. U can make a flowchart on just about anything: database design, program flow, painting a wall, changing a tire on a car. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148283 Share on other sites More sharing options...
pandu Posted December 16, 2010 Author Share Posted December 16, 2010 Anti-Moronic thanks for all the great suggestions on tools and advice! I am going thru the link on db normalization. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148287 Share on other sites More sharing options...
Anti-Moronic Posted December 16, 2010 Share Posted December 16, 2010 But a tool is only as good as the operator. if you don't have any exposure to a tool, (Flowcharting, OOP, PHP, Hand Drill, Car) that tool to you is useless. So even if we provide you with a list of the tools we find helpful, the only way to use those tools effectively is by using them and learning them. Very true. However, the ONLY reason I know and use the above tools is because I studied what tools a developer should be using. What tools other 'guru' developers use. If I didn't, I might have ended up using excel to design my databases and wordpad to code my applications. It's my responsibility to validate the suggestions. For example, when I first started I wish I'd found a thread on here which had the complete tool-set suggestions of the most experienced developers. With that, I would have gone out and researched these tools, their uses and such and been in a much better position. Instead, I thought notepad++ was all I 'needed' to create any web application. Git or SVN didn't even cross my mind. It *should* have because I should have read about version control but a list of suggested tools brings with it a list of suggested areas which are so important they warrant their own tools. by the way, what 'tools' do you use? Things you find indispensable? EDIT: in fact, to add to this: the only reason I started using notepad++ or questioned what editor or IDE I was using is because somebody suggested it. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148293 Share on other sites More sharing options...
pandu Posted December 16, 2010 Author Share Posted December 16, 2010 I totally agree! Having a single post on tools and what they are used for, would really be useful. It would also save time for gurus who can just point to the link. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148315 Share on other sites More sharing options...
laffin Posted December 18, 2010 Share Posted December 18, 2010 Zend Studio - Windows\Linux - Big Projects/Debugging. The Debugger is by far the best UltraEdit - Windows - Its commericial, but a very excellant editor Geany - Linux - Excellant all around editor editor MySQL Workbench - Windows/Linux - The DB Modeling is excellant for designing DB's. MySQLcc - Windows/Linux - A Quick way to edit DB's (Think of myphpadmin but an app) Dia - Windows/Linux - Diagram editor, used on occasion when speed is more of an issue (quick & dirty) Expresso - Windows - Regex Design & Tester GeneratorData - online - When you need some sample data WinMerge - Windows - Comparison & Patch tool Portability DevPHP - Windows - Editor/Debugger (primarily used for debugging) Notepad++ - Windows - Editor. np++ although not geared for debugging, it's still an excellant editor. XDebug Prolly some other tools I can throw in, but thats the builk of the tools. My Comment above, was for the newer coders actually. Some of the tools do have a higher learning curve than others. Some tools are just overwhelming of what they can do. But as with any tool, experience comes with practice and usage. Quote Link to comment https://forums.phpfreaks.com/topic/221820-advice-on-how-to-convert-idea-to-code/#findComment-1148917 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.