I have read several ways to use GParamSpec. I thought GParamSpecBoxed helps wrap struct however i would like to implement a GObjec, GDate and add custom validations, only future date for example. Could you help me?
I expect to extend GParamSpec
Related
Can any one guide me how can I implement this library.
Basically I want to Implement basic table with paggination.
A better option is to use DataTable from react-native-paper.
You can find an example on how to use it here.
I am new to Salesforce apex coding. My first class that I am developing has 10 methods and is some 800 lines.
I haven’t added much of exception handling, so the size should swell further.
I am wondering, what the best practice for Apex code is... should I create 10 classes with 1 method instead of letting 1 class with 10 methods.
Any help on this would be greatly appreciated.
Thanks
Argee
What do you use for coding? Try to move away from Developer Console. VSCode has some decent plugins like Prettier or Apex PMD that should help you with formatting and making methods too complex. ~80 lines/method is so-so. I'd worry about passing long lists of parameters and having deeply nested code in functions rather than just their length.
There are general guidelines (from other languages, there's nothing special about Apex!) that ideally function should fit on 1 screen so programmer can see it whole without scrolling. Read this one, maybe it'll resonate with you: https://dzone.com/articles/rule-30-%E2%80%93-when-method-class-or
I wouldn't split it into separate files just for sake of it, unless you can clearly define some "separation of concerns". Say 1 trigger per object, 1 trigger handler class (ideally derived from base class). Chunkier bits not in the handler but maybe in some "service" style class that has public static methods and can operate whether called from trigger, visualforce, lightning web component, maybe some one-off data fix would need these, maybe in future you'd need to expose part of it as REST service. And separate file for unit tests (as blasphemous as it sounds - try to not write too many comments. As you're learning you'll need comments to remind yourself what built-in methods do but naming your functions right can help a lot. And a well-written unit test is better at demonstrating the idea behind the code, sample usage and expected errors than comments that can be often overlooked).
Exception handling is an art. Sometimes it's good to just let it throw an exception. If you have a method that creates Account, Contact and Opportunity and say Opportunity fails on validation rule - what should happen? Only you will know what's good. Exception will mean the whole thing gets rolled back (no "widow" Accounts) which sucks but it's probably "more stable" state for your application. If you naively try-catch it without Database.rollback() - how will you tell user to not create duplicates with 2nd click. So maybe you don't need too much error handling ;)
I am designing an ODK survey form using XlsForm. On this form I have set some regex constrains that have pretty much the same structure except for some parts that are different. For example
regex(.,'^farmer-[mM][aA][dD][fF][aA][iI]-\d{5}$').
I have used something similiar
regex(.,'^[mM][aA][dD][fF][aA][iI]-\d{5}$')
as a constraint on another question. What I want to achieve is How to reuse or bind the expression by setting it in one place and only referencing it in different questions. Any help is very much appreciated. Thank you
You can do this by creating a type=calculate that stores the regex and then refer to it in your questions when necessary. Make sure to put the calculation inside quotation marks.
While I was using Construct 2, I decided I wanted to see what the code that the events were creating looked like. Is there a way to do so?
You have to export your project in order to view the final JavaScript.
Ashley from Scirra wrote in a similar topic:
Many users are worried about reverse-engineering, so the exported Javascript code is deliberately obfuscated and difficult to work with.
I find myself using a certain helper a lot in Views. I call it like this:
$this->MyHelper->foo()
It's a big nuisance to type this construct every time. I wish i could use a shortened version instead:
foo()
It should be available in Views.
How do i do that?
That's what IDE and type-completion is for.
You will open a can of worms and collisions with such an approach.
Also it doesn't make your code any more useful or better to understand btw.
The opposite: It is destined to blow up.
But if you must you can create yourself wrappers to access it via
$this->foo()
as long as there is no collision and you write yourself a custom View class to allow that.
foo() itself - if you think about it - is not possible as this would require static access and destroys the whole idea of reusable objects.
But again: It's a bad idea to begin with.
It is a simple PHP variable assigning technique:
Use:
$obj = $this->MyHelper;
$obj->foo();
Hope this will be helpful to you.