✔ Conventional Naming In Java | (Video 17)
Naming Conventions in programming languages are guidelines for deciding the name of an identifier. We are not forced to follow the conventions but they are good to follow for code readability and maintenance. In this video, you will see common conventions in Java for a Package, Class, Method, and Variable.
✔ Package starts at 0:46
✔ Class starts at 13:36
✔ Method starts at 17:14
✔ Variable starts at 21:40
✔ Questions, Answers, & Practice starts at 27:02
► Link to download the Transcript, Presentation, and Code =
https://www.rexjones2.com/java-conventional-naming/
► Free Selenium PDF Book: https://www.rexjones2.com/book-selenium-4-beginners/
► Free Java PDF Book: https://www.rexjones2.com/book-part-1-core-java/
► All Paperback & eBooks: http://tinyurl.com/Rex-Allen-Jones-Books
► Increase Video Quality: Settings - Quality - Select HD
► CC Font Size: Settings - Subtitles/CC - Options - Font Size
► Turn CC On or Off: Click CC
► Transcript
Hello everybody, Welcome To Selenium 4 Beginners. My name is Rex Allen Jones II. In this video, I will cover the naming convention for Java packages, classes, methods, and variables. Conventional is conforming to standards that are accepted by Java. It is possible for those conventions to change from company to company and project to project.
I’ve been on projects that have a document stating what they want and how they want things done. However, I am going to share the most used conventions for Java.
Our tutorial plan will cover the following: How To Name A Package, How To Name A Class, How To Name A Method, How To Name A Variable, followed by Questions, Answers, & Practice. The practice is always optional but I know Practice Makes Improvement.
Let’s start with How To Name A Package. In our previous sessions, I did not use a conventional naming standard for the packages. As we can see, there is a default package and a package called Building Blocks which was created in our session Building Blocks For Selenium.
Convention is a standard but we do not have to use that standard.
Know what, I am getting ahead of myself. Before we get into the package naming convention. Give me a moment to explain package. What is a package? A package is a group of classes with 2 purposes for each class.
Number 1 a package is used to organize classes as a group. It is beneficial to the programmer when related classes are grouped together. Number 2 a package is used to control access to the class. Classes can be defined as public to accept outside code and defined as private without an access modifier to prevent outside code.
All classes belong to a package. In Eclipse and our screenshot, we see a default package with 3 classes: DataTypes, Print_Statements, and SystemDotSetProperty. By default, classes are placed in the default package when no package name or package statement is provided for that class.
When a package name is provided, that class is placed into a particular package. In this example, Building Blocks is the package while Search_T_SHIRTS, Search_T_SHIRTS_TestNG, and Search_T_SHIRTS_Highlight are the classes. The compiler does not allow 2 classes to have the same name in the same package.
However, 2 classes can have the same name in different packages. It is expected for packages to be written in all lowercase letters. To create a package, right click source which is src, select New, then Package. A warning or error message will show up if we start with anything other than a lowercase letter.
Watch what happens when I enter a special character “Invalid package name”. If I enter a dot, the message states “A package name cannot start or end with a dot”. A warning shows up if we enter a capital letter “Discouraged package name. By convention, package names usually start with a lowercase letter”. Notice it did not show an error but a warning that stated it is discouraged.
Why is it discouraged? One of the reasons why It is discouraged because all lowercase letters for a package name separates packages from a class, a method, and a variable. By convention, a class, method, and variable can have uppercase as well as lowercase letters.
Now, let’s dive deeper into the naming convention for a package. Many organizations use their internet domain for their package name but in reverse order. For example, I have a domain called selenium4beginners.com. Currently, there’s no articles or videos on the site but it’s available as a domain. As a package name in reverse order, I would write com dot then selenium4beginners.
The same is true for testng.org. If we look at class Search_T_SHIRTS_TestNG, the import statements start with org.testng. That is the reverse domain for testng.org. Go to a browser and type testng.org. Here is the website for TestNG and the book I suggested at the end of video (Part 2) Building Blocks For Selenium.
#SeleniumTraining #SeleniumAutomation #BeginnerSeleniumTutorials #SeleniumWebDriver
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «✔ Conventional Naming In Java | (Video 17)», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.