- 8 лучших редакторов кода для мобильных устройств
- Dcoder
- Turbo Editor
- Quoda
- QuickEdit
- Our Code Editor Free
- Android Web Developer (AWD)
- Android Interactive Development Environment (AIDE)
- Codeanywhere
- Understanding Clean Code in Android
- Before you start writing your code, it’s better that you understand how to manage your code and how to make your code scalable.
- What is “Clean Code”?
- — Must I care about it?
- Characteristics of a Clean code
- Create Meaningful Names
- — Class Names
- — Method Names
- — Use Problem Domain Names
- Writing your code using S.O.L.I.D Principles
- Single Responsibility Principle — SRP
- Open-Closed Principle — OCP
- Liskov Substitutions Principle — LSP
- Interface Segregation Principle — ISP
- Dependency Inversion Principle — DIP
- Conclusion
8 лучших редакторов кода для мобильных устройств
Зачем нужен редактор кода в смартфоне? Это свобода писать код когда и где угодно. Предугадать, когда в голову придет гениальная идея (или понадобится срочно внести исправление в проект), невозможно. Зато вполне можно заранее установить приложение-редактор в смартфоне и в случае необходимости набирать код с большим удобством, чем в блокноте.
Dcoder
Как утверждается на сайте Dcoder, это самая быстрая мобильная IDE. Она доступна в веб-версии, а также в виде приложений для iOS и Android. Поддерживает большое количество языков (больше 35), включая HTML, CSS, JavaScript, C, C++, Python и Java.
В Dcoder есть автоматическое проставление парных скобок и создание отступов, подсветка синтаксиса. Также вы сможете выбрать тему оформления приложения.
Разработчики Dcoder гордятся маленьким весом своего приложения: всего 6MB. Такую легковесность удалось достичь благодаря использованию облачных компиляторов и облачного хранилища для кода. Но тут есть и обратная сторона: чтобы использовать приложение, нужно непременно быть онлайн.
Turbo Editor
Простой, но при этом мощный текстовый редактор для Android. Имеет открытый исходный код (т. е., при желании и должном умении вы сможете его усовершенствовать по своему вкусу). В этом редакторе вы найдете подсветку синтаксиса для HTML, XHTML, CSS, LESS, JavaScript, PHP, Python и многих других языков, а также режим чтения, автосохранение файлов при выходе из приложения, просмотр результатов работы в браузере.
Quoda
Quoda это простой в использовании редактор кода для Android. Как и другие редакторы в нашем списке, Quoda поддерживает много языков, включая C, C++, C#, CSS, HTML, Java, JavaScript, Lua, Markdown, PHP, Python, Ruby. Есть подсветка синтаксиса, расширенная клавиатура, функционал поиска и замены с применением регулярных выражений и учетом регистра.
В платной версии доступны автодополнение кода, интеграция SFTP/FTP(S) и облачных хранилищ, а также предпросмотр страниц в разметке HTML/Markdown (на планшетах).
QuickEdit
Быстрый, надежный редактор, в котором есть функционал для работы как с простым текстом, так и с кодом. Как утверждают разработчики этого приложения, к его отличительным особенностям можно отнести скорость работы и отзывчивость. По этим критериям QuickEdit превосходит многие аналогичные приложения.
В этом приложении вы найдете подсветку синтаксиса для 50 с лишком языков, возможность включать и выключать нумерацию строк, поддержку физической клавиатуры, плавную прокрутку, автоматическое определение кодировки, возможность отмены действий (без ограничений). Поддерживается доступ к файлам в облачных хранилищах.
Our Code Editor Free
Как следует из названия, этот редактор бесплатный (но есть показ рекламы). А как указано в описании на Google Play, это целая IDE для Android. Причем она может работать без подключения к интернету. Правда, в таком случае вам не удастся поработать с файлами в облачных хранилищах (а вообще такая возможность есть).
Android Web Developer (AWD)
AWD — это IDE для веб-разработки. Языков и форматов поддерживает не много: PHP, CSS, JS, HTML, JSON. Есть возможность дистанционной работы с проектами (по протоколам FTP, FTPS, SFTP, WebDAV).
В AWD вы найдете (среди прочего) подсветку синтаксиса, автодополнение кода, автоопределение кодировки файла, интеграцию Git (в платной версии), функционал поиска и замены с применением регулярных выражений, поддержку физической клавиатуры.
Android Interactive Development Environment (AIDE)
AIDE — это интегрированная среда разработки для создания Android-приложений прямо на Android-устройствах. Поддерживает Java, C/C++, HTML5, CSS и JavaScript.
В этом приложении вы найдете автодополнение кода, проверку ошибок, подсветку синтаксиса для Java и XML. Есть интеграция с Dropbox. Благодаря совместимости с Eclipse можно открывать Eclipse-проекты. Для профессиональной разработки поддерживается Git.
Отличительная черта этого приложения — интерактивные уроки кодинга с пошаговыми инструкциями (курс программирования на Java, Android-разработки, создания игр).
Казалось бы, все просто отлично, но в комментариях люди жалуются на невозможность сохранять файлы в бесплатной версии и на навязчивые предложения перейти на платный вариант.
Codeanywhere
IDE для работы на Android-устройствах. Включает в себя редактор кода, FTP-клиент и терминал. Поддерживает огромное количество языков (больше 100). Есть возможность подключения к сторонним сервисам (Dropbox, Google Drive, OneDrive, Amazon S3, Github, Bitbucket).
Если у вас нет собственного сервера, Codeanywhere может запустить для вас Linux-контейнер, в котором будут доступны, к примеру, WordPress, Drupal, Magento.
По мотивам статьи «Top 8 Code Editors for Mobile Application Development».
Источник
Understanding Clean Code in Android
Before you start writing your code, it’s better that you understand how to manage your code and how to make your code scalable.
As Uncle Bob said in his book,
You are reading this “article” for two reasons. First, you are a programmer. Second, you want to be a better programmer. — Robert C. Martin
Like what he said, imagine that you are in a library, and you are looking for some books. If the library sorted and categorized their books, you will find your books faster. In addition, the cool interior design & architecture will make you feel comfortable inside the library while you are searching for your books.
Just like writing books, if you want to build something great, you have to know how to write and organize your code neatly. If you have team members or someone else that has your (legacy) code, they just need to see the variable names or packages or classes and they will understand right away. They don’t need to say “F**k” this code and start it again from zero.
What is “Clean Code”?
As you can see, it is not good enough if you finish your development faster if others cannot understand your code, because it will become another tech debt.
Your code has a definition of “Clean” if it can be understood easily by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility, and maintainability.
— Must I care about it?
The reason why you must care about your code is that your code will describe your thought process to others. That is why you have to start thinking about making your code more elegant, simple and readable.
Characteristics of a Clean code
- Your code should be elegant: Your code should make you smile the way a well-crafted music box or well-designed car would.
- Your code has been taken care of: Someone has taken the time to keep it simple and orderly. They have paid appropriate attention to details. They have cared.
- Your code has to be focused: Each function, each class, each module exposes a single-minded attitude that remains entirely undistracted, and unpolluted, by the surrounding details.
- Contains no duplication
- Runs all the tests
- Minimize the number of entities such as classes, methods, functions, and the like.
One difference between a smart programmer and a professional programmer is that the professional understands that clarity is king. Professionals use their powers for good and write code that others can understand. — Robert C. Martin
Create Meaningful Names
Choosing good names takes time but saves more than it takes. The name of a variable, function, or class, should answer all the big questions. It should tell you why it exists, what it does, and how it is used. If a name requires a comment, then the name doesn’t reveal its intent.
Let’s take a sample:
— Class Names
Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account, and AddressParser. Avoid words like Manager, Processor, Data, or Info in the name of a class. A class name should not be a verb.
— Method Names
Methods should have verb or verb phrase names like postPayment, deletePage, or save. Accessors, mutators, and predicates should be named for their value and prefixed with get, set, and is according to the javabean standard.
— Use Problem Domain Names
When there is no “ programmer-eese” for what you’re doing, use the name from the problem domain. At least the programmer who maintains your code can ask a domain expert what it means.
Before we continue, take a break and make some coffee or grab some snacks. 😀
OK, now we continue about the writing your code using S.O.L.I.D principles.
Writing your code using S.O.L.I.D Principles
This principles are invented by Robert C. Martin (Uncle Bob), SOLID is a term describing a collection of design principles for good code.
Single Responsibility Principle — SRP
It means every class should have a single responsibility. There should never be more than one reason for a class to change. Just because you can add everything you want into your class doesn’t mean that you should. Split big classes into smaller ones, and avoid God Classes.
Lets take a sample:
We have an RecyclerView.Adapter with business logic inside onBindViewHolder.
It makes RecyclerView.Adapter not having a Single Responsibility because it has a business logic inside onBindViewHolder. This method is only responsible for setting up data into its view binding implementation.
Open-Closed Principle — OCP
Software entities should be open for extension but closed for modification. What it means is that if you write a Class A, and then your teammates want to make a modification in a function inside Class A, They can easily do that by extending Class A, instead of making a modification inside Class A.
The easy example would be the RecyclerView.Adapter class. You can easily extend this class and create your own custom adapter with custom behavior without modifying the existing RecyclerView.Adapter class.
Liskov Substitutions Principle — LSP
Child classes should never break the parent class’ type definitions.
It means that a subclass should override the methods from a parent class that does not break the functionality of the parent class. For example, you create an interface class that has an onClick() listener, and then you apply the listener in MyActivity and give it a toast action when the onClick() is called.
Interface Segregation Principle — ISP
The interface-segregation principle (ISP) states that no client should be forced to depend on methods it does not use.
It means that if you want to make a Class A and implement it in another class ( (Class B), it should not override all Class A methods inside class B. To make it clear and easy to understand,
Let’s take a sample: inside your activity, you need to implement SearchView.OnQueryTextListener() and only need the onQuerySubmit() method.
How to achieve that? simple, you just create a callback and a class that extends to SearchView.OnQueryTextListener().
And here is how to implement in view:
Or, if you are using Kotlin, you can use the Extension Function:
And last, here is how to implement in view:
Dependency Inversion Principle — DIP
Depend on Abstractions. Do not depend on concretions.
Uncle Bob’s definition of the Dependency Inversion Principle consists of two points:
- High-level modules should not depend on low-level modules. Both should depend on abstractions.
- Abstractions should not depend on details. Details should depend on abstractions.
High-level modules, which provide complex logic, should be easily reusable and unaffected by changes in low-level modules, which provide utility features. To achieve that, you need to introduce an abstraction that decouples the high-level and low-level modules from each other.
The easy example is in MVP pattern, you have an object of interfaces that help us to communicate with concrete classes. What it means is, UI classes (Activity/Fragment) don’t need to know the actual implementation of methods in Presenter. So, if you have any changes inside presenter, UI classes don’t need to know or care about the changes.
Let’s see it in this code example:
Now let’s see it in UserActivity:
So what we do is we create an interface which abstracts the implementation of a presenter and our view class keeps the reference of the PresenterInterface.
Conclusion
Mature programmers know that the idea that everything is an object is a myth. Sometimes you really do want simple data structures with procedures operating on them. From now, you have to start thinking about what to implement and about future perspective that will be easy to update.
I know that if you have created an app before with nonsense naming, God classes, Spaghetti code, trust me, I have done the same thing. That’s why I share my knowledge about the Clean Code from Uncle Bob to you, and it is also be a reminder for me and I hope I can help you to understand it.
Last but not least, Comments/Suggestions are welcome as always. Keep learning and keep sharing.
Источник