{"id":65948,"date":"2021-07-18T04:10:05","date_gmt":"2021-07-18T08:10:05","guid":{"rendered":"http:\/\/bangla.salearningschool.com\/recent-posts\/code-conventions-for-the-java-programming-language-java-short-notes\/"},"modified":"2021-07-18T04:10:05","modified_gmt":"2021-07-18T08:10:05","slug":"code-conventions-for-the-java-programming-language-java-short-notes","status":"publish","type":"post","link":"http:\/\/bangla.sitestree.com\/?p=65948","title":{"rendered":"Code Conventions for the Java Programming Language #Java Short Notes"},"content":{"rendered":"<p><b>Why Have Code Conventions?<\/b><\/p>\n<ul>\n<li> 80% of software life cycle is spent on software         maintenance.    <\/li>\n<li> Hardly the original author maintains a software    <\/li>\n<li> Code Conventions improve the readability of the          software    <\/li>\n<li> If you require to ship your source code as a product,         code conventions make your product well packaged <\/li>\n<\/ul>\n<p><b>Java Code Conventions<\/b><\/p>\n<ul>\n<li> Avoid assigning several variables to the same value          in a single statement    <\/li>\n<li> Avoid using an object to access a class (static)          variable or method. Use a class name instead    <\/li>\n<li> Don&#8217;t make any instance or class variable public          without good reason. When the class is essentially          a data structure, you can use public instance          variables    <\/li>\n<li> Two blank lines: Between sections of a source file,          between class and interface definitions     <\/li>\n<li> One blank line: Between methods, between the local          variables in a method and its first statement,          before a block or single-line, between logical          sections inside a method    <\/li>\n<li> Blank spaces: Between a keyword and parenthesis,         after commas in argument lists, after Casts    <\/li>\n<li> Each line should contain at most one statement    <\/li>\n<li> One declaration per line is recommended    <\/li>\n<li> Initialize local variables where they&#8217;re declared   <\/li>\n<li> Put declarations only at the beginning of blocks    <\/li>\n<li> No space between a method name and the parenthesis   <\/li>\n<li> Methods are separated by a blank line   <\/li>\n<li> Four styles of implementation comments: block,         single-line, trailing, and end-of-line   <\/li>\n<li> Documentation comments describe Java classes,         interfaces, constructors, methods, and fields. Use         \/**&#8230;*\/ for doc comments   <\/li>\n<li> Doc comments: One comment per class, interface, or         member    <\/li>\n<li> Doc comments: Should appear just before the         declaration   <\/li>\n<li> Avoid lines longer than 80 characters   <\/li>\n<li> Break longer lines: after a comma, before an        operator, Prefer higher-level breaks to lower-level         breaks, align new lines with the previous line, or         indent the new line with  8 spaces     <\/li>\n<li> You can get a detailed code conventions at <a href='http:\/\/java.sun.com\/docs\/codeconv\/html\/CodeConvTOC.doc.html' target='new' rel=\"noopener\">Java Code Conventions<\/a><\/li>\n<\/ul>\n<p> From: http:\/\/sitestree.com\/?p=4865<br \/> Categories:Java Short Notes<br \/>Tags:<br \/> Post Data:2012-09-01 18:46:01<\/p>\n<p>\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com\/' target='new' rel=\"noopener\">https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\t(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http:\/\/Training.SitesTree.com' target='new' rel=\"noopener\"> http:\/\/Training.SitesTree.com<\/a><br \/>\n\t\tIn Bengali: <a href='http:\/\/Bangla.SaLearningSchool.com' target='new' rel=\"noopener\">http:\/\/Bangla.SaLearningSchool.com<\/a><br \/>\n\t\t<a href='http:\/\/SitesTree.com' target='new' rel=\"noopener\">http:\/\/SitesTree.com<\/a><br \/>\n\t\t8112223 Canada Inc.\/JustEtc: <a href='http:\/\/JustEtc.net' target='new' rel=\"noopener\">http:\/\/JustEtc.net (Software\/Web\/Mobile\/Big-Data\/Machine Learning) <\/a><br \/>\n\t\tShop Online: <a href='https:\/\/www.ShopForSoul.com'> https:\/\/www.ShopForSoul.com\/<\/a><br \/>\n\t\tMedium: <a href='https:\/\/medium.com\/@SayedAhmedCanada' target='new' rel=\"noopener\"> https:\/\/medium.com\/@SayedAhmedCanada <\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why Have Code Conventions? 80% of software life cycle is spent on software maintenance. Hardly the original author maintains a software Code Conventions improve the readability of the software If you require to ship your source code as a product, code conventions make your product well packaged Java Code Conventions Avoid assigning several variables to &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/bangla.sitestree.com\/?p=65948\">Continue reading<\/a><\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1917],"tags":[],"class_list":["post-65948","post","type-post","status-publish","format-standard","hentry","category-fromsitestree-com","item-wrap"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":65844,"url":"http:\/\/bangla.sitestree.com\/?p=65844","url_meta":{"origin":65948,"position":0},"title":"Java : SCJP: Important Resources #Java Short Notes #SCJP","author":"Sayed","date":"July 16, 2021","format":false,"excerpt":"How to use generics to avoid runtime errors. More Generics Class casting in Java: How to avoid runtime exception - ClassCastException: overloading, overriding, variable and method hiding Java HotSpot virtual machine What Java Technology can do? Offers from Java Technology Java:Common Problems (and Their Solutions) Benefits of OOP: Modularity, Information-hiding,\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":65822,"url":"http:\/\/bangla.sitestree.com\/?p=65822","url_meta":{"origin":65948,"position":1},"title":"SCJP: Language Fundamentals #Java Short Notes #SCJP","author":"Sayed","date":"July 15, 2021","format":false,"excerpt":"Class declaration and java source file. Only \"one\" top-level public class is allowed per java source file. The name of the java source file and the name of the top-level public class MUST be the same. If no public class is there in a file, after compiling separate class files\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":67688,"url":"http:\/\/bangla.sitestree.com\/?p=67688","url_meta":{"origin":65948,"position":2},"title":"Java: Some basic important stuffs #Computer Game Design #Java Short Notes","author":"Author-Check- Article-or-Video","date":"July 27, 2021","format":false,"excerpt":"Data types to represent telephone numbers:a string of ten digits can represent all ten-digit telephone numbers.an object can hold data (integers or strings) of the elements of a telephone numberan integer data type can represent all ten-digit numbers--a boolean can only represent two valuesan enumerated type can only represent a\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":26557,"url":"http:\/\/bangla.sitestree.com\/?p=26557","url_meta":{"origin":65948,"position":3},"title":"Accesses instance variables in a Ship object. #Programming Code Examples #Java\/J2EE\/J2ME #Object Oriented Programming","author":"Author-Check- Article-or-Video","date":"April 28, 2021","format":false,"excerpt":"Test1.java Accesses instance variables in a Ship object. ******************************************************** \/\/ Create a class with five instance variables (fields): \/\/ x, y, speed, direction, and name. Note that Ship1 is \/\/ not declared \"public\", so it can be in the same file as \/\/ Test1. A Java file can only contain\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":10528,"url":"http:\/\/bangla.sitestree.com\/?p=10528","url_meta":{"origin":65948,"position":4},"title":"Accesses instance variables in a Ship object.","author":"","date":"August 29, 2015","format":false,"excerpt":"Test1.java Accesses instance variables in a Ship object. ******************************************************** \/\/ Create a class with five instance variables (fields): \/\/ x, y, speed, direction, and name. Note that Ship1 is \/\/ not declared \"public\", so it can be in the same file as \/\/ Test1. A Java file can only contain\u2026","rel":"","context":"In &quot;Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8&quot;","block_context":{"text":"Code . Programming Samples . \u09aa\u09cd\u09b0\u09cb\u0997\u09cd\u09b0\u09be\u09ae \u0989\u09a6\u09be\u09b9\u09b0\u09a8","link":"http:\/\/bangla.sitestree.com\/?cat=1417"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":27247,"url":"http:\/\/bangla.sitestree.com\/?p=27247","url_meta":{"origin":65948,"position":5},"title":"Using the this reference in class Ship3 #Programming Code Examples #Java\/J2EE\/J2ME #Advanced Swing","author":"Author-Check- Article-or-Video","date":"May 15, 2021","format":false,"excerpt":"\/.\/.\/.\/.\/.\/.\/.\/.\/.\/. \/\/ Give Ship3 a constructor to let the instance variables \/\/ be specified when the object is created. \/.\/.\/.\/.\/.\/.\/.\/.\/.\/ class Ship3 { public double x, y, speed, direction; public String name; public Ship3(double x, double y, double speed, double direction, String name) { this.x = x; \/\/ \"this\" differentiates\u2026","rel":"","context":"In &quot;FromSitesTree.com&quot;","block_context":{"text":"FromSitesTree.com","link":"http:\/\/bangla.sitestree.com\/?cat=1917"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=65948"}],"version-history":[{"count":0,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=\/wp\/v2\/posts\/65948\/revisions"}],"wp:attachment":[{"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=65948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=65948"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/bangla.sitestree.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=65948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}