|By Michael Zuskin||
|November 26, 2012 07:45 AM EST||
Give all entities mentioned in the code (DB tables, DB tables' fields, variables, classes, functions, etc.) meaningful, descriptive names that make the code easily understood. The names should be so self-explanatory that it eliminates the need for comments in most cases.
Use the words per and by as often as possible - they really simplify a developer's life. A variable's name li_cows_per_farm is better than li_total_cows, and a function name uf_retrieve_city_by_country tells us more than uf_retrieve_city, especially if it doesn't have parameters that supply the "by what" information.
Don't use abstract words like "actual" and "total' in variables names as they will madden you, forcing to spend extra time trying to understand what is "actual," what is "not actual" and which grouping level is "total" for. Is li_total_cows field total per barn? per farm? per village? per province? per country? per the Universe? If, for example, per farm, then how will you name the total per village? It's also "total"! So, don't write simply "total" - write total PER WHAT! Use only exact definitions that produce no (or minimum) questions, even if that results in longer variables names.
*** BAD code: ***
ldc_total_salary = ldc_actual_salary * ldc_total_hours
*** GOOD code: ***
ldc_salary_per_day = ldc_salary_per_hour * ldc_hours_per_day
Don't produce different versions of a same entity name (like emp_id / employee_id, inv_num / invoice_num).
When you use values retrieved from database tables, try to name the corresponding variables exactly by the DB fields (of course, adding naming convention prefixes where needed). But you can use local variables' names more freely, especially when the coded logic is complicated while the tables fields are not informative enough (see the previous rule).
Long, Descriptive Names
The common, obvious practice is to give variables and functions short names. But, sometimes, there are situations when it makes sense to break that rule and use long, "real-English" names that will clearly describe what they are for.
For example, it can be done when a variable is in a rare use (like an instance var, which is referenced only a couple of times), but not a local var which is mentioned in the code many times. Anyway, don't be afraid to give long names any time you feel it will simplify working with the code. See the difference between:
is_main_filter = uf_get_main_filter()
is_filter_by_selected_row_in_summary_win = uf_get_filter_by_selected_row_in_summary_win()
As you can see, names of variables can tell the whole story. Even if it makes a line too long, there is no problem breaking it into two lines - it's better than looking at a variable and having no idea what is stored in it (or to search its declaration in hopes that a clarifying comment exists). But remember - names of that style should be an exception, not a rule.
Exact Action Timing
Names describing actions must express if the action should be done in the future or was done in the past.
Giving names to variables, don't force readers to guess an action timing. A good example of a bad variable name is lb_is_calculation. How must the condition "if lb_is_calculation then..." be understood? As you can see, there is no problem exists understanding what it means if the variable is named lb_is_calculation_done (lb_is_calculated) or in the imperative form - lb_do_calculation (or simply lb_calculate).
The common advice is to use words do..., ...to_do, perform..., execute..., ...to_apply, etc., for stuff that should take place in the future, and ...done, ...performed, ...executed, ...occurred, ...passed, ...applied, etc., for things that have taken place in the past.
Constants for [Meaningless] Application Codes
Don't hard code numbers if they are not apparent - use constants instead.
Okay, it's still possible to understand what "if li_inv_year > 2011..." or "if li_month = 4..." is but what do you want to say to a programmer who has written "if li_window_mode = 3..." or "if li_inv_status = 8..."?
Local and Instance Constants Management
Giving names to local and instance constants, divide the family prefix from the mnemonic description by two underscores.
Now let's discuss local and instance-scope constants. Their names must consist of two parts:
- Group (or "family") - like "ORDER_STATUS" or "INVOICE_STATUS". A few constants of the same family can co-exist in the scope (for example, an order can have many statuses). In fact, it's a prefix before the main descriptive part.
- Description (or mnemonic part) - like "OPEN" or "CLOSED". There can be many constants with the same description (for example, both - an order and an invoice - can have the status "OPEN").
Using two underscores (instead of one) to connect both parts will allow code readers to easily distinguish between them, especially when each part consists of a number of words. For example:
constant string ORDER_STATUS__OPEN = "OPN"
constant string ORDER_STATUS__CLOSED = "CLS"
constant string ORDER_STATUS__CANCELED = "CNCL"
constant string INV_STATUS__OPEN = "OPN"
constant string INV_STATUS__CLOSED = "CLS"
constant string INV_STATUS__CANCELED = "CNCL"
Global Constants Management
Constants, used globally (in different parts of the application), must be declared in not-autoinstantiated NVOs - one NVO per each constants group (or "family") - and accessed via the automatically created global reference variable with the same name, without declaring additional variables and creating instances.
For example, you can have an NVO named n_color for color constants, n_order_status for order statuses constants, etc. It's a good idea to keep them all in one PBL so developers can easily check if the NVO for the group they need already exists or must be created. The constants are declared in the instance variables declaration section in a very straightforward way. Here is a possible set for n_order_status:
constant string OPEN = "OPN"
constant string CLOSED = "CLS"
constant string CANCELED = "CNCL"
If you open any not-autoinstantiated class in the "View Source" mode, you can see that PowerBuilder automatically creates a global variable of that object's type with the same name as the class (PB doesn't know that we add "g" to global vars! :-D ). For example, if you create n_order_status class (not-autoinstantiated, remember?) and look at its source, you'll see the following line:
global n_order_status n_order_status
That's exactly the mentioned declaration of the global var. You don't need to declare a variable of the object each time you need to use a constant in your script - you already have a variable ready for use. That's how you mention a constant in the code:
Looking pretty similar to enum of C# but, unfortunately, it's not an enumerated type; you cannot declare a function argument of type n_order_status and pass to that function one of the statuses (which is of type string) defined in the type - you can only pass a reference to n_order_status object, which doesn't solve the problem of passing type-safe arguments. You can make the argument of type string to pass a particular status, but this approach doesn't supply type safety - nothing prevents you from passing an invoice status or even the name of your cat...
Pay attention that PowerBuilder only declares a global variable; it doesn't create an object referenced by that variable. Practically it means that we can use only constants because they belong to a type (not an instance) definition (something similar to static data in C#). If you try to access an instance variable or a function of that global var, then you will get the "Null object reference" error. As opposed to C#, which will happen even if the function doesn't access instance data, so there is nothing like C#'s "static function" behavior in PowerBuilder.
For standalone constants (not belonging to any family) create one common NVO named, let's say, n_const.
Through WebRTC, audio and video communications are being embedded more easily than ever into applications, helping carriers, enterprises and independent software vendors deliver greater functionality to their end users. With today’s business world increasingly focused on outcomes, users’ growing calls for ease of use, and businesses craving smarter, tighter integration, what’s the next step in delivering a richer, more immersive experience? That richer, more fully integrated experience comes about through a Communications Platform as a Service which allows for messaging, screen sharing, video...
Sep. 3, 2015 04:00 AM EDT Reads: 724
Containers are not new, but renewed commitments to performance, flexibility, and agility have propelled them to the top of the agenda today. By working without the need for virtualization and its overhead, containers are seen as the perfect way to deploy apps and services across multiple clouds. Containers can handle anything from file types to operating systems and services, including microservices. What are microservices? Unlike what the name implies, microservices are not necessarily small, but are focused on specific tasks. The ability for developers to deploy multiple containers – thous...
Sep. 3, 2015 03:15 AM EDT
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
Sep. 3, 2015 02:30 AM EDT Reads: 1,677
SYS-CON Events announced today that the "Second Containers & Microservices Expo" will take place November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Containers and microservices have become topics of intense interest throughout the cloud developer and enterprise IT communities.
Sep. 2, 2015 11:45 PM EDT Reads: 641
In his session at @ThingsExpo, Lee Williams, a producer of the first smartphones and tablets, will talk about how he is now applying his experience in mobile technology to the design and development of the next generation of Environmental and Sustainability Services at ETwater. He will explain how M2M controllers work through wirelessly connected remote controls; and specifically delve into a retrofit option that reverse-engineers control codes of existing conventional controller systems so they don't have to be replaced and are instantly converted to become smart, connected devices.
Sep. 2, 2015 11:15 PM EDT Reads: 232
Akana has announced the availability of the new Akana Healthcare Solution. The API-driven solution helps healthcare organizations accelerate their transition to being secure, digitally interoperable businesses. It leverages the Health Level Seven International Fast Healthcare Interoperability Resources (HL7 FHIR) standard to enable broader business use of medical data. Akana developed the Healthcare Solution in response to healthcare businesses that want to increase electronic, multi-device access to health records while reducing operating costs and complying with government regulations.
Sep. 2, 2015 10:00 PM EDT Reads: 311
SYS-CON Events announced today that IceWarp will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. IceWarp, the leader of cloud and on-premise messaging, delivers secured email, chat, documents, conferencing and collaboration to today's mobile workforce, all in one unified interface
Sep. 2, 2015 06:00 PM EDT Reads: 466
SYS-CON Events announced today that Micron Technology, Inc., a global leader in advanced semiconductor systems, will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Micron’s broad portfolio of high-performance memory technologies – including DRAM, NAND and NOR Flash – is the basis for solid state drives, modules, multichip packages and other system solutions. Backed by more than 35 years of technology leadership, Micron's memory solutions enable the world's most innovative computing, consumer,...
Sep. 2, 2015 05:30 PM EDT Reads: 272
SYS-CON Events announced today the Containers & Microservices Bootcamp, being held November 3-4, 2015, in conjunction with 17th Cloud Expo, @ThingsExpo, and @DevOpsSummit at the Santa Clara Convention Center in Santa Clara, CA. This is your chance to get started with the latest technology in the industry. Combined with real-world scenarios and use cases, the Containers and Microservices Bootcamp, led by Janakiram MSV, a Microsoft Regional Director, will include presentations as well as hands-on demos and comprehensive walkthroughs.
Sep. 2, 2015 04:45 PM EDT Reads: 401
SYS-CON Events announced today that Pythian, a global IT services company specializing in helping companies leverage disruptive technologies to optimize revenue-generating systems, has been named “Bronze Sponsor” of SYS-CON's 17th Cloud Expo, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. Founded in 1997, Pythian is a global IT services company that helps companies compete by adopting disruptive technologies such as cloud, Big Data, advanced analytics, and DevOps to advance innovation and increase agility. Specializing in designing, imple...
Sep. 2, 2015 04:15 PM EDT Reads: 359
17th Cloud Expo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterprises are using some form of XaaS – software, platform, and infrastructure as a service.
Sep. 2, 2015 04:00 PM EDT Reads: 1,589
With the Apple Watch making its way onto wrists all over the world, it’s only a matter of time before it becomes a staple in the workplace. In fact, Forrester reported that 68 percent of technology and business decision-makers characterize wearables as a top priority for 2015. Recognizing their business value early on, FinancialForce.com was the first to bring ERP to wearables, helping streamline communication across front and back office functions. In his session at @ThingsExpo, Kevin Roberts, GM of Platform at FinancialForce.com, will discuss the value of business applications on wearable ...
Sep. 2, 2015 04:00 PM EDT
The 3rd International WebRTC Summit, to be held Nov. 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA, announces that its Call for Papers is now open. Topics include all aspects of improving IT delivery by eliminating waste through automated business models leveraging cloud technologies. WebRTC Summit is co-located with 15th International Cloud Expo, 6th International Big Data Expo, 3rd International DevOps Summit and 2nd Internet of @ThingsExpo. WebRTC (Web-based Real-Time Communication) is an open source project supported by Google, Mozilla and Opera that aims to enable bro...
Sep. 2, 2015 03:45 PM EDT Reads: 1,569
WebRTC services have already permeated corporate communications in the form of videoconferencing solutions. However, WebRTC has the potential of going beyond and catalyzing a new class of services providing more than calls with capabilities such as mass-scale real-time media broadcasting, enriched and augmented video, person-to-machine and machine-to-machine communications. In his session at @ThingsExpo, Luis Lopez, CEO of Kurento, will introduce the technologies required for implementing these ideas and some early experiments performed in the Kurento open source software community in areas ...
Sep. 2, 2015 02:15 PM EDT
Consumer IoT applications provide data about the user that just doesn’t exist in traditional PC or mobile web applications. This rich data, or “context,” enables the highly personalized consumer experiences that characterize many consumer IoT apps. This same data is also providing brands with unprecedented insight into how their connected products are being used, while, at the same time, powering highly targeted engagement and marketing opportunities. In his session at @ThingsExpo, Nathan Treloar, President and COO of Bebaio, will explore examples of brands transforming their businesses by t...
Sep. 2, 2015 02:00 PM EDT Reads: 270
SYS-CON Events announced today that HPM Networks will exhibit at the 17th International Cloud Expo®, which will take place on November 3–5, 2015, at the Santa Clara Convention Center in Santa Clara, CA. For 20 years, HPM Networks has been integrating technology solutions that solve complex business challenges. HPM Networks has designed solutions for both SMB and enterprise customers throughout the San Francisco Bay Area.
Sep. 2, 2015 01:30 PM EDT Reads: 948
While many app developers are comfortable building apps for the smartphone, there is a whole new world out there. In his session at @ThingsExpo, Narayan Sainaney, Co-founder and CTO of Mojio, will discuss how the business case for connected car apps is growing and, with open platform companies having already done the heavy lifting, there really is no barrier to entry.
Sep. 2, 2015 12:45 PM EDT Reads: 201
Too often with compelling new technologies market participants become overly enamored with that attractiveness of the technology and neglect underlying business drivers. This tendency, what some call the “newest shiny object syndrome,” is understandable given that virtually all of us are heavily engaged in technology. But it is also mistaken. Without concrete business cases driving its deployment, IoT, like many other technologies before it, will fade into obscurity.
Sep. 2, 2015 12:15 PM EDT Reads: 420
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
Sep. 2, 2015 11:30 AM EDT Reads: 2,002
As more intelligent IoT applications shift into gear, they’re merging into the ever-increasing traffic flow of the Internet. It won’t be long before we experience bottlenecks, as IoT traffic peaks during rush hours. Organizations that are unprepared will find themselves by the side of the road unable to cross back into the fast lane. As billions of new devices begin to communicate and exchange data – will your infrastructure be scalable enough to handle this new interconnected world?
Sep. 2, 2015 11:15 AM EDT Reads: 194