Organizing Script Includes in ServiceNow | Share the Wealth

  Рет қаралды 1,384

GlideFast Consulting

GlideFast Consulting

Күн бұрын

Пікірлер: 10
@ChuckTomasi
@ChuckTomasi 2 жыл бұрын
Great stuff. I take exception to comments in your script includes, as someone who has had to use someone else's code, comments at the beginning defining purpose, inputs and outputs is often the only "documentation" you get. Ideally, it should be self-documenting, but I've found that's rarely the case so I give my future self and others a helping hand.
@davidarbour9549
@davidarbour9549 2 жыл бұрын
You're right Chuck, self-documenting (or ideally-written) code is very rare, but it is what I always strive for. I should say that well built code should not need many comments. In practice, if I come to a point where I feel the next dev will need a better understanding of the code, I try to break that out into a new function. When that's not possible or practical, I will add a comment. What I take the most issue with when it comes to comments is when the comments don't add any value to the code.
@ChuckTomasi
@ChuckTomasi 2 жыл бұрын
@@davidarbour9549 Thanks David. More recently, I find myself writing polymorphic functions (e.g. a parameter can be a GlideRecord or sys_id. A little clarification in situations like this goes a long way.)
@davidarbour9549
@davidarbour9549 2 жыл бұрын
@@ChuckTomasi Yeah, that's one case where documentation is absolutely critical! Speaking of, if I had a wishlist for JavaScript features, I think overloaded functions would be at the top of my list.
@ProfessorTimbo
@ProfessorTimbo 2 жыл бұрын
Re: refactoring -- Get an IDE like Webstorm, and SHIFT+F6 to safe-refactor and code-search! It's fantastically useful. There's even a checkbox for "refactor comments" as well.
@davidarbour9549
@davidarbour9549 2 жыл бұрын
I'm a VS Code junkie, but I am intrigued by Webstorm.
@JohnCaruso
@JohnCaruso 2 жыл бұрын
Just wanted to mention that when you use this method of script include organization (i.e., a function that returns an object and does not use `this` or `prototype`, also known as a Factory Function), then you don't need to use the `new` operator. E.g., var service = GlideService('my_table'); // works fine
@davidarbour9549
@davidarbour9549 2 жыл бұрын
Yes, but not using 'new' just looks weird to me. I guess it's just habit at this point.
@Motorcyclemelee
@Motorcyclemelee 2 жыл бұрын
How do you unit test your script include’s private functions?
@davidarbour9549
@davidarbour9549 2 жыл бұрын
I don't unit test the private functions. If a public function fails, there's a limited number of places I will have to look to figure out what's going on because I keep functions very small and focused. The private functions in this video were built for demonstration purposes. In practice, I don't use private functions very often because I can typically break those functions out into one or more other script includes.
ServiceNow Widget Best Practices | Share the Wealth
42:17
GlideFast Consulting
Рет қаралды 789
Share The Wealth: Introduction to Vault
32:33
GlideFast Consulting
Рет қаралды 179
Mom Hack for Cooking Solo with a Little One! 🍳👶
00:15
5-Minute Crafts HOUSE
Рет қаралды 22 МЛН
UFC 310 : Рахмонов VS Мачадо Гэрри
05:00
Setanta Sports UFC
Рет қаралды 1,2 МЛН
Senior Developers vs. Junior Developers, What's The Difference?
14:21
Continuous Delivery
Рет қаралды 32 М.
TypeScript Origins: The Documentary
1:21:36
OfferZen Origins
Рет қаралды 298 М.
Share the Wealth | NERC CIP-009: Recovery Plans for BES Cyber Systems
33:34
The Right Way To Build Async APIs in ASP.NET Core
20:12
Milan Jovanović
Рет қаралды 20 М.
The New Outlook is TERRIBLE
20:19
Chris Titus Tech
Рет қаралды 16 М.
Auto-Populate Variable || UTAH Features || ServiceNow
6:47
Share the Wealth: Public Sector Digital Services (PSDS) ServiceNow
32:28
GlideFast Consulting
Рет қаралды 99
Was I Wrong About Blazor? | Coding Shorts 111
16:35
Shawn Wildermuth
Рет қаралды 27 М.
Exposing the not-so-secret practices of the cult of DDD - Chris Klug -
1:03:10
A Nightmare on CMDB Street: Protecting Systems and Networks, NOW | Webinar
53:39