Basics of coding. Coding is the “new black”


1. On your own

If you have iron willpower and a burning desire to become a programmer, then you can achieve your goal through self-education. This is not the easiest or shortest path: you will have to understand the information chaos yourself and fight procrastination. But you can study at a convenient time for relatively little money or for free.

The easiest way to start is with interactive online courses. There are many on the Internet, the materials of which clearly explain the basics of programming and set the direction for further development. Pay special attention to those courses that teach using examples of real projects, that is, they tell you step by step how to create a specific program or website.

Platform with free web development courses freeCodeCamp

Remember that you won't succeed without practice. Study in project-oriented courses and try to write programs and websites based on them yourself. Look for lectures on YouTube about projects that you would like to develop. First, copy other people's work and analyze it. Then try to move away from the original, experiment, change individual elements until you can create something unique.

In addition to courses and video lectures, there is official documentation available on language websites, and. Once you understand the basics, look for the latest publications with the subtitle Best Practices for your chosen programming language. Such books contain the best development techniques.

Be sure to set a goal to create your own project and constantly work on it.

This will help you consolidate your knowledge and understand what information you still lack. Your skills will develop along with the project. When you finish it, work on a new one - more difficult.

If you have any difficulties during the learning or development process, you can always turn to programming communities like Toaster and Stack Overflow for any question. For example, they will help you solve a problem, choose a good course, or point out errors in the code.


Questions and answers service on technological topics “Toaster”

It is convenient to hone your skills on special platforms where you can compete with other programmers, solving various practical problems using code. Such services include Codewars, TopCoder and HackerRank.

If you feel that your development has reached a dead end, or want to speed up your learning, try the following options.

2. With the help of a mentor

A mentor is a personal mentor who points out mistakes, warns about pitfalls, and helps chart a course of study. A useful recommendation received at the right time can save you from many problems and save a lot of time. Therefore, a mentor will not hurt anyone.

Find out if any of your friends are developers. Perhaps one of them will want to help you. If you don’t know such people, you can look for them in programming communities. For example, on the same “Toaster”. Only mentoring services are not cheap, and no one wants to spend a lot of time on strangers for nothing.

3. Teachers of “live” courses

Distance and face-to-face courses with teachers who teach programmers from scratch have become incredibly popular in recent years. In this format you will also have to work a lot on your own. But you will study according to a professionally prepared program, and the solutions to the problems will be checked by a living person. The disadvantages of the courses include the high cost of training.

Popular Russian-language online platforms that provide systematic training for programmers: “Netology”, GeekBrains and Loftschool.

If you prefer to study in person, you can look for educational centers that teach programming in your locality. Unfortunately, such establishments are most often found only in large cities. An example is the STEP computer academy, which has branches in several countries.

4. At the university

If you have a lot of time on your hands and you are sure that you want to spend your life programming, you can study computer science at university. But keep in mind that traditional educational institutions lag behind progress, so you will have to master modern programming languages ​​and other technologies on your own.

On the other hand, the university will provide fundamental knowledge of mathematics, algorithms and other areas that will help you become a highly qualified programmer. Over the years of diligent study, you will develop the right type of thinking, thanks to which you will grasp everything on the fly in the professional field.

How to choose a direction and language

In the IT industry, there are several areas, each of which uses its own set of languages. We list the main directions in order of increasing complexity:

  1. Web development. Popular languages: JavaScript, PHP, Python, Ruby.
  2. Mobile development. Popular languages: Java, Swift.
  3. Development of games and programs for desktop computers. Popular languages: C++, C#, C.
  4. Big Data, machine learning. Popular languages: Python, R, Scala.

What to look for when choosing

To make the right choice of direction and, in particular, language, consider the following factors: the difficulty of mastering and the number of training materials on the Internet, your personal preferences (what exactly you want to develop) and the demand for the language in the labor market.


Graph of the demand for languages ​​on the international labor market / research.hackerrank.com

You can easily check the demand for a language in your region on job search sites. Just open the section for software developers and see the number of available vacancies.

If you can't decide

If you're confused, take a look at JavaScript, the language in which almost the entire web is written. Many organizations and programmers advise beginners to choose this language as their first language.

For example, the founder of the educational resource freeCodeCamp Quincy Larson JavaScript for beginners. Larson makes a very simple argument:

  1. JavaScript is relatively easy to learn. And to write something and run it in this language, all you need is a code editor and a browser.
  2. JavaScript is the most in-demand language on the international labor market and has great prospects. Large companies like Google, Microsoft and Facebook are investing in the JavaScript ecosystem.
  3. JavaScript has a very wide range of applications: from websites and browser games to mobile applications.

In addition, a large developer community has formed around this language. The high interest in JavaScript provides a huge number of courses, books and other educational content.

What else should a programmer know: mathematics and English?

Any programmer would benefit from a deep understanding of . For fields such as game graphics development or big data, a mathematical mind is a must. But when it comes to web development and creating simple programs, in most cases you can do without mathematics. Although there is no consensus among professionals on this matter.

But understanding English, at least at the level of fluently reading documentation, is mandatory for all programmers. Official documents and most educational materials appear primarily in English. often become outdated before the translation is even published. In addition, knowledge of English opens up prospects for working with the whole world.

How to get your first experience and first job

To find your first job as a programmer, you must have a portfolio. This is a project you created, or better yet several, that demonstrate all your developer skills. Most courses include developing projects that can be included in your portfolio.

A very valuable item on your resume will be work experience, especially team development. But where can you get it if you are looking for your first job?

  1. Complete several orders on . This could be Freelansim or Upwork. Offer your services for free, then the first customers will come to you.
  2. Find like-minded people and create a common project with them. People unite for such purposes at almost every educational platform where there are programming courses.
  3. Select courses whose organizer helps with job placement. For example, at GeekBrains, after training, you have access to internships from different companies, including paid ones. GeekUniversity and STEP guarantee employment to their graduates.

Before doing this, don’t forget to search the Internet for lists of tasks and questions that are often asked to job seekers.

The ability to program is one of the most valuable skills in demand in the modern world. And it practically doesn’t matter what exactly makes a person create code: sincere interest, financial or career considerations - those who know how to program will not be left idle. Coding is very similar to communicating in a foreign language, so the first stages of learning programming can often be difficult for beginners. Many people experience severe discomfort, but over time everything gets better and the person begins to code easily, without much mental effort. Today you can find many books and online resources with which you can learn to code, but any self-study is associated with stress and negative emotions - this should always be remembered when starting to master any programming language. The most important thing for a beginning coder is not to give up learning a language halfway, losing all interest in this activity. So what does a future programmer need to know? What difficulties await him on the way to mastering useful skills?

Programming languages

First you need to decide on the programming language that the beginner wants to learn. It's not that simple - there are many languages ​​and each of them is good in its own way. It is very important to choose a language consciously - after all, a lot of time and effort will be invested in mastering it. But be that as it may, a novice coder needs to know that there are no good and bad programming languages, but there are languages ​​that are friendly to neophytes. Therefore, the easier and more understandable the programming language is, the better - at the beginning of the journey it is better to go from success to success, from simple tasks to more complex ones. It will be easier later, after a beginner learns to code in his first programming language, other languages ​​will be much easier for him.

It is also very important to immediately decide what language knowledge is needed for. Because coding is very different. If someone wants to become a software developer, then you can look towards Java, and in the case of creating applications for iOS, the Swift language is better suited.

Suitable teaching method

There are many ways to learn, so in the case of programming languages, you need to find the right method. In this case, it would be wise to choose a main method and supplement it with secondary methods of teaching. Everything here is very individual: if a beginner is visual or good at perceiving information by ear, then he can learn coding by watching videos on YouTube, and gain other knowledge from books. Here are some simple but effective training schemes:

Online coding courses. Some people work more effectively when they are told what to do and have their performance checked regularly. And there are a lot of such people. Therefore, if a beginner feels that he has problems with self-discipline, then he should choose a course where he will be constantly motivated by tests. This is a good idea - many people give up learning programming, relying on their willpower and enthusiasm. Learning to code on your own is not for everyone, but you should always keep that in mind.

Video on YouTube. Today you can learn everything about everything just by watching videos on YouTube. More experienced coders show you exactly what to do, so this type of material is very helpful. It's a simple, effective, and most importantly free way to learn to code. If you have access to the Internet, then you can sit, watch, repeat all day until it becomes clear.

Books. It's a bit of an old-fashioned way to learn programming languages ​​these days, but the fact remains that coding hasn't changed much over the years and what's taught on YouTube isn't much different from what's said in a paper book. But books have an undoubted advantage - with their help it is easier to understand the logic of the language, and this is incredibly important. First of all, because when it comes to practical training, no one wants to do something that is not clear or does not work out. To avoid giving up halfway, you should definitely read books on programming.

Practice. Many of the best programmers are self-taught. Very often they started coding without realizing it because their learning was haphazard. They encountered a problem, solved it, encountered another - and also solved it. Gradually, such self-taught people move from one problem to another, more complex one, and at the same time master coding. There’s no point in imitating such people, but you can’t give up on practice – it’s the key to success in learning.

Recording success

A beginner just starting to learn a programming language needs to know and be prepared for the fact that it will take a long time. Learning to code is a long process in which failures are felt much more strongly than successes. In order not to abandon your studies, you must record all your actions. People very often lose motivation just because they cannot feel progress. And it will definitely happen if the beginner studies diligently. It’s just that skills grow imperceptibly; a novice coder may not even notice it, he moves towards his intended goal in such small steps.

That's why you need to remind yourself from time to time how far you have come and look back more often. This helps a lot - after all, looking at their first lines of code, anyone can understand that they are progressing. It may seem like all these personal records are just fun. No, in fact, recording your successes is very important - it is highly motivating throughout the entire learning process. Therefore, in order to start and not give up, you must mark each completed stage.

Clear training terms

When it comes to coding, a common mistake many newbies make is that they try to do a bunch of tasks at once and tend to give up on them all before finishing. They become interested in something else, most often other tasks, so they jump from one project to another. You shouldn't do that. It is best to move systematically - solve one problem or understand an example until everything becomes clear. It's a very simple principle: one thing at a time.

But at the same time, you need to understand that moving forward is necessary, so you need to set yourself strict deadlines for studying this or that aspect of the language. You can try to imagine that there will be an exam soon and you will have to show everything that you have achieved. It motivates. Yes, all these personal tasks may not be very comfortable, but coding in itself is not entertainment. Strict discipline will allow you to gain the necessary skills, and meeting deadlines is almost the most important skill for a freelance programmer.

While ordinary users are afraid of making a mistake and really don't like it when things go wrong, the programmer is in a completely different position. Mistakes are part of his work, and a very large part. Therefore, a new coder must teach himself to read error messages, no matter how unpleasant it may be. Such messages contain a lot of valuable information, as they tell what exactly was missed during the code creation process. You need to be prepared that such messages will appear very often and will not go away even after learning the programming language is completed. You should not spare time to work on mistakes - this is the most important part of learning. In addition, this is a good practice - once you understand the problem, it will be easier to avoid making many mistakes later. Error messages are not a punishment, in fact they are the coder's best friends who want to teach him how to do everything correctly.

Communication with other programmers

Such communication will also help you understand that other people just as often encounter coding problems and there is nothing unusual about this. And if a beginner, in addition, can help his programmer friend, then he will get a second wind and will continue his studies with redoubled force. And you shouldn’t be afraid of communication - programmers are actually friendly people, they’re just often on “their own wavelength” and a beginner just needs to resonate.

Right and wrong approach

Novice coders often try to copy pieces of code from other projects when solving some of their own problems. They think this is reasonable, because the main thing is to make sure everything works. This is a wrong and, moreover, a very harmful approach. And not because copying is bad, but because by copying, a beginner will not understand what exactly this code does. Of course, copying is much easier than writing everything yourself.

But during the learning process, this approach will lead to large gaps in knowledge and the novice coder will one day give up, unable to solve the problem facing him. And he will abandon everything. When learning a programming language, you need to spend time without regrets analyzing any problem, even a seemingly insignificant one. And if you can’t come up with a solution right away, you can’t give up. You need to read, watch videos, ask others - a beginner needs to thoroughly understand the difficulties that have arisen. Although he is learning a language, it is not quite the same as learning an ordinary, human language. The coder is dealing with a machine, so it is important for him to understand what he is doing. Such knowledge of the language is simply invaluable when the learning process comes to practice.

Learning programming languages ​​is not the most exciting thing. But everything can be corrected if you approach the matter with imagination. There is no better way to learn anything than by playing games. This also applies to coding, as you can quickly learn a language just by playing and improving your skills at the same time. Here are a few games that a newbie coder should consider.

  • CheckiO is a game that you can play in your browser and requires solving problems in JavaScript or Python to progress through the game.
  • CodeMonkey - Mainly designed for kids, but if you are a beginner, you can learn some code by playing this game.
  • Codewars is not a real game, but rather a collaborative problem solving solution for programmers. This is a great way to learn coding as the game supports many languages.
  • Code Combat is an online platform where you can learn to code by playing a real game.

There are many other games you can use, it all depends on which ones suit you and the language you are learning best. The game will help a beginner start to think like a programmer, and this is very important at the very beginning of training.

Conclusion

Some people learn to code quickly, others more slowly, but anyone can learn a programming language. And you shouldn’t rush into things faster if something doesn’t work out. You can reach your goal by moving slowly, and indeed any learning is a slow process. If a beginner does not want to give up learning coding after mastering only the basics, he needs to develop his own strategy of behavior. You need to understand that time, effort, and sometimes money are invested in training, so you just need to move from one stage to another. And don’t give in to difficulties. Yes, programming is not for everyone. But anyone can master a language and learn to code. So you just need to make up your mind and follow your own path.

And I'll explain why.

Fifteen years ago I was advised to become a programmer due to the fact that I was an introvert and a shy person, as well as having an analytical mind and a complete lack of social life, but I just laughed and brushed off such advisers. I was a teenager then, and in my teenage mind, the programmer lived forever in the basement of his parents' house, was pimply and wore ugly glasses, he never had a girlfriend, but his fantasies about Princess Leia (and quite frequent ones) made up for it. I didn't like this lifestyle. In addition, then I already had a girlfriend, and quite a beautiful one.

Fast forward six years, I'm sitting at the Budapest airport reading a book about HTML...

After another six years, I was hired by a Northern Irish startup company as a generalist. Yes, it looks like it took some time. But how much exactly? I can not say exactly. But a lot. Mythical 10 thousand hours? No. If I were asked to give an approximate figure, I would say that by that day I had “coded” about 8 thousand hours. Technically speaking, if you believe the 10 thousand hours rule, then after 2 thousand I would become an expert in this field.

But will I?

This is what I managed to achieve in 8 thousand hours. Make yourself comfortable, because my story will be long. I coded in the following languages: C, HTML, CSS, JavaScript, Java (Android), Swift, PHP, Ruby, Python, Chuck, SQL, worked with the following frameworks: Node, Angular, Bootstrap, Foundation, React, Rails, CodeIgniter, Ionic and has created landing pages, WordPress sites, e-commerce solutions, eLearning content, Moodle and Totara sites, Mahara sites, Common Cartridge and SCORM packages, Android and iOS programs, hybrid programs, internal web applications, e-books, magazines, games, and additional applications for board games. So where am I going with this?

My point is that there is no field as such, so the task of becoming an expert in it is unattainable. Coding is not a field. Computer science - yes, but it's completely different.

Coding is something that presidents, teachers and parents are pushing the younger generation towards, as if leading sheep to golden fields of opportunity.

This promise is a dream, a propaganda so well crafted and expressed (they don't even put it into words now) that it has been absurdly simplified to pictures so that the cute crawling toddlers will understand that logical thinking is more important than the desire to feed themselves (please note the sarcasm) .

Fifteen years later, coding has become the pop culture version of programming, and the public now has high hopes for a future army of coders that will bring us AI-controlled homes, traffic, retail, entertainment, and revolutions in medicine, industry, and sex - just a madhouse, there is no other word. And all because programming is presented as coding, but in theory it is easy to learn. But this is so far from the truth...

Source: LifeHacker

Let's figure it out. The accepted “fact” of the myth that anyone can master a programming language in just a few hours is only true up to a point, and that point comes early in the learning process. Indeed, a language can be learned in one day. In general, if you set yourself the goal of becoming a polyglot in programming in a month, while still having a job, you can master 8-10 languages ​​if you study on weekends. But here's the rub. Each programming language has its own libraries as well as syntactic features, and all of this cannot be learned easily or quickly or in a weekend. Actually, in the real world, the programming language will not be the main problem.

Just because you speak English doesn't mean you can write novels or even short stories. The same can be said about coding.

Just because you've learned a language doesn't mean you know how to write a program. Add to this a myriad of frameworks, plugins, libraries, preprocessors, postprocessors, coding standards, industry standards, Test Driven Development (TDD), Behavior Driven Development (BDD), Content Management Systems, File Versioning, Continuous Integration (CI), Release Management and deployment, debugging, ticketing, waterfall models - and scrum methods, as well as combinations of them, and I'm not sure I've named them all yet. The point is that the term "coder" covers pretty much everything mentioned above. Programming affects only a small part. Important, but still small.

However, programming continues to be simplified...

Apple launched Playgrounds, MIT launched Scratch, and Lego is preparing Boost, and everyone is trying to sell coding to the younger and younger generations, as if they want to fill the jobs of new programmers in the 2020s.

The way I see it is: "Don't worry about the code, take these virtual puzzle pieces and that's it, you can program." If only this were true. Here's what you need to know about programming: It's text-based. It always has been and will be for many years to come. Kids who play Lego Boost, Playgrounds, or Scratch will not become more proficient programmers by age 22 than those who started learning programming at 16 and worked with a real programming language. Actually, where do such expectations come from? I don’t think that my child will learn to earn his own bread until he is 22 years old. But if he studies coding for 6 years, then I guarantee that he will quickly find a job.

Playgrounds from Apple.

Coding - « new black»


In 10 years, coding will likely become such a natural skill that coding easily will be as natural to teenagers as reading and writing fluently. If you don’t start now, there is a great risk of finding yourself in an unpromising situation when the cultural gap between several generations becomes so great that it separates contemporaries into different “centuries.”

The ability to code shortens the path from an idea to your project in a broad sense (game, website, business, application, social online project, etc.) to a minimum: you came up with it yourself - you did it yourself. In any case, a prototype, if serious development of programming skills does not follow. There is a point of view that it is difficult to develop a relevant product with innovative ideas, usability and features without understanding how it will work at the code level.


What understandings are primarily needed in order to move from the idea of ​​​​the cosmic complexity of these skills and knowledge to action?

  • These are colossal new opportunities and prospects.
  • Millions of people on the planet know how to do this.
  • The entire Internet, all modern devices, all the “smart” infrastructure into which our everyday life, work and life in general are included - all this was created by these several million people: they realize their ideas, develop civilization and earn money (often more than good money) .
  • If you remove psychological barriers for yourself like “it’s too difficult, I can’t do it” and simply enroll in courses or register on the platform, your chances of mastering programming will become somewhat higher.
  • Coding - " new black " And“new English”, that is, a natural and obligatory skill. Surely it won’t “go” the first time, but in general, since it is available to so many people in the world, you can persist and master it.

Where and how to study? There are options: free and for different money, online at home and offline in schools.

Offline paid


Moscow Coding School (MCS)

Website : MosCoding.ru

"Coding is the new black" - one of the slogans that you will first see on the siteMosCoding.ru. Among other things, they encourage you to code, code, and code again, they promise to provide cyber tours for digital workouts, so thatturn hipsters into hackers.

If serious, there is a big event in Moscow: the Moscow Coding School (MCS) opened recently. Its founders are Kirill Zhvalov and Vadim Rezvy. School partners : Dream Industries, W-O-S, SoundCloud, Look At Media and Innova Systems. Classes will be held in the multifunctional space DI Telegraph (Dream Industries) in the Central Telegraph building. The level of students is beginners and experts who want to improve their professionalism. They will teach coding, web and mobile development. Moscow Coding School promises to become a fashionable school for representatives of creative professions (start-ups, journalists, bloggers, artists, designers, etc.). As a good bonus - pleasant and useful networking. They start with three courses: “Basics of HTML and CSS”, “Dynamic Web with jQuery” and “Web Developer Tools”.

  • "Basics of HTML and CSS"(RUB 9,999). Teacher - Mikhail Reizlin, SoundCloud developer. Duration - 4 days on weekends, 3-hour classes with a break. It is recommended to bring a laptop with a pre-installed Google Chrome browser and Sublime Text text editor.The course program includes: web standards; state of the industry; developer tools; browser differences; construction and website design; workspace setup and creation of the first website; HTML5, basic HTML tags and elements; semantic markup; changing the appearance of pages using CSS; element selector system; attributes; positioning elements on the page; layout layout from psd file; tools for working with layout (Chrome Web Inspector, Firefox Debugging Tools); web typography (Google Fonts, Typekit); CSS3 features; website optimization; hosting and DNS; Zen Coding (do less and accomplish more); secrets of advanced CSS positioning; isolating problems by elimination, etc.


  • "Dynamic web with jQuery"(RUB 9,999). Teacher - Roman Gordeev, Front-End developer of Third Place and Exchang.es (Dream Industries) projects. Duration - 4 days on weekends (February 15, 16, 22, 23), 3-hour classes with a break. To complete the course, it is recommended to know the basics of HTML/CSS. Bring with you a laptop with any operating system and a pre-installed Google Chrome browser. The course program includes: jQuery JavaScript library; JavaScript basics; working with selectors; DOM model; examples of effects and animation; modifying web pages using the browser console; browser event model; page changes depending on user actions; mouse and keyboard events; jQuery plugins; practical work.

  • "Web developer tools"(RUB 9,999). Teacher - Sergey Chikuenok, chief web technologist at Innova Systems, creator of the Emmet.io plugin. Duration - 4 days on weekends (March 1, 2, 8, 9), 3-hour classes with a break. The course program includes: visual, text and IDE editors; review of useful online tools; browser tools for debugging HTML, CSS and JavaScript; quick search for errors in layout; debugging and optimization of JavaScript, searching for “slow” places on a web page; tools for “live” editing; familiarization with version control systems using GitHub as an example; connection to the development of Open Source projects; hosting your websites on GitHub; template engines and preprocessors; assembling the project before launching the site; automatic project testing and automatic optimization. Accordingly, it is recommended that you master the basics of HTML/CSS to complete the course.



Training takes place in the format of small tasks, the user immediately sees the result of the actions on the desktop. To ensure that free students do not lose motivation, the platform gives reward badges for passing sections, tests and assignments and monitors their progress, giving tips along the way.


How realistic is it to learn something on your own using the service? It makes sense to go to the Success Stories section.


Interestingly, the Codecademy platform is not only about learning, but also about teaching coding: anyone can become the author of a course.


Website: Teamtreehouse.com

On Treehouse, training is also provided in video format - these are 1000 lessons on programming, web design and technology entrepreneurship. You can gain basic knowledge, learn how to create websites, applications for iPhone or Android, and learn languages ​​(for example, Ruby on Rails).

Treehouse has its own YouTube channel, which is worth subscribing to. In general, training on Treehouse costs $250-490 per year, but there is also a free platform project - Code Racer: if your English is not yet good enough to gain real knowledge and skills for the indicated amounts, it is wise to take a closer look at the free project.


Code School

Website: CodeSchool.com

The Code School platform, which teaches coding under the motto “Learn by Doing,” also has a base (5-level courses in HTML/CSS, Ruby, JavaScript, etc. with 15-minute video lectures, exercises, emulation results and feedback), and« trick» - gamification of coding training. These include, for example, awarding badges for successfully completed tasks and fun courses like Rails for Zombies: you program what interests and entertains you - and, accordingly, motivates.

Writing code can be the hardest part of the software development process. If you don't organize everything from the very beginning (especially for large projects), coding and debugging afterwards will not only take a lot of time but also cause a lot of headaches.

Good code is well maintained, reusable, and testable. The following steps will show you and/or your development team how to handle various software tasks and keep everything as good as possible. I'll introduce you to “best practices” that will help you write good code and help keep you and your team happy and efficient.

1. Use coding standards

It's easy to write bad, disorganized code, but hard to maintain such code. Good code usually maintains some standards for variable naming, formatting, and so on. Such standards are useful because they make things consistent for those who then read the code afterwards, including you.

You can create your own coding standards, but it is better to use one that is widely used. Using the Zend Framework Coding Standard, or PSR-1 Coding Style, will make it easier for others to adapt.

2. Use comments

Comments are critically needed. You won't learn to appreciate them until you write a thousand lines of sizing code, leave it for a couple of days, and then come back and try to figure it out. Useful comments make life easier for those who will work with the code after you.

Write clear, one-line comments for unclear sections of code; write a complete description of the parameters and functionality of functions and methods; for complex logic blocks, describe the logic before them if necessary. Don't forget to update your comments!

3. Refactor

Refactoring code is also a good habit for productive developers. Believe it or not, you have to refactor your code daily otherwise there is something wrong with it! Refactoring keeps your code in good shape, but what needs to be refactored and how?

You should refactor everything, from architecture to methods and functions, variable names, number of arguments passed to a method, and the like.

Refactoring is more of an art than a science, but there are a few good rules that can shed some light on it:

  • If your function or method is more than 20-25 lines, there is likely too much logic in there and you can split it into two or more smaller functions/methods.
  • If the name of your function or method consists of more than 20 characters, it is worth revising the name, or revising the entire function/method using the first rule.
  • If you have many nested loops, you are using too many resources without realizing it. In general, you might want to reconsider your logic if you've nested more than two loops. Three nested loops - just terrible!
  • Consider whether there are suitable design patterns that you can use. You shouldn't use patterns just for the sake of using patterns, but patterns offer proven solutions that may be suitable.

4. Avoid global code

Global variables and loops can add problems when your code grows to millions of lines. They affect the code in places where it is difficult to see, or cause problems with the names of variables, objects, and other things. Think twice before polluting the global namespace with variables, functions, loops, etc.

Ideally, you should not define any blocks globally. Switch statements, try-catch statements, foreach loops, while loops, and the like must be declared inside a method or function. Methods should be described inside classes, and classes and functions inside namespaces.

5. Use names with meaning

Never use names like $k , $m and $test for your variables. How can such code be read in the future? In good code, names of variables, methods/functions, classes; must carry a semantic load. Some good names for variables: $request , $dbResult and $tempFile (Depends on your coding style).

6. Use structures meaningfully

Structuring your application is important; do not use complex structures, always keep it simple. When naming directories and files, use a naming convention that you have agreed upon with your team, or that meets coding standards. Always separate the four parts of a PHP application from each other - CSS, HTML Templates, JavaScript, PHP code - and for each, try to separate the libraries from the business logic. It's also a good idea to keep the directory hierarchy as small as possible, this will make it easier to find parts of the code and navigate the structure.

7. Use version control systems

In the past, good development teams trusted CVS. Now, we have a variation of available solutions. Change and revision management should be simple but effective, so choose whatever version control system will work best with your development team's flow. I prefer to use a distributed version control system like Git or Mercurial; both are free/open source and very powerful. If you don't know what a version control system is, I recommend you check out Sean Gudgston's Introduction to Git series.

8. Use automatic construction tools

9. Use code documenters

For large applications spanning multiple classes and namespaces, you should have automatically generated API documentation. This is very useful and everyone on the team will know “what is what.” And if you work on several projects at the same time, you will find this documentation a blessing, because you will probably forget the specifics of the structure and other differences between projects. One such document maker you may want to consider is DocBlox.

10. Use Testing

There are many tools that I really value, but one that I clearly value is frameworks that help automate the testing process. Testing (namely systematic testing) is important for every part of your million dollar application. Good testing tools are PHPUnit and SimpleTest for unit testing your PHP Classes. For GUI testing, I recommend SeleniumHQ tools.

Bottom line

In this article, you've seen an overview of the best practices for writing better code, from using coding standards to team formatting, the importance of refactoring and how to master it, and using professional tools like a testing framework, code documenter, and version control to help you manage code base. If you don’t still adhere to these steps, you should accustom yourself and your team to them.







2024 gtavrl.ru.