Is the default constructor created if I provide another one? - plsql

I haven't found anything about this.
In PL/SQL, if I provide a constructor for an object, the default one will still be created, or it's like in C++ or Java?

Yes, the default constructor is still there. Incidently, if you create another constructor with the same name and arguments you'll get an error PLS-307: too many declarations of ... when you try to use it.

Related

overriding a constructor

This is a simple questions. I have researched this questions in my notebooks and books and the internet but cant find an answer
Why would we override the default constructor by adding parameters to it?
You would create a constructor for a class to manipulate its member variables according to whatever other conditions as soon as it's created. I get the impression you don't actually know what a constructor is.
Many languages (like C++/C#/Java) automatically create default no-arguments constructor when none defined in the class explicitly.
When you create a constructor in a class with or without arguments usually compiler stop creating default auto-generated constructor (depending on language specification). This is done on assumption if you have some non default initialization than automatically generated one is likely to not create object in a state you would expect.
Since having constructor with arguments is natural way to create objects it is essentially lead to "removing" default auto-generated constructor which probably can be called "overriding default constructor".

How to correct the objection about dymanic Object type by FlexPMD?

I have the code in one of my flex file used as labelFunction in a DataGrid.
When I run the FlexPMD to do the code review, it generates an objection about the dynamic type object used in the following method signature and it suggests to use strongly type object.
public function getFormattedCreatedTime(item:Object, column:DataGridColumn):String {
var value:Date=item[column.dataField];
return dateFormatter.format(value);
}
Does anyone know how to rectify it?
Thanks
You have the answer in your question - just use a strongly type object, or perhaps an interface if item can have various types.
But basically there's nothing wrong with using dynamic type objects as long as you know what you're doing. I'd say just ignore the error.
In this case it would be of course possible to type item to something less generic than Object, but some times you can't, or Object is exactly the right type, in this case you can use //NOPMD comment - it will instruct the PMD validator to skip the definition. Of course the good practice is to also explain the reason you used //NOPMD.

DataService.commitRequiredOn() recursive check?

We're using LCDS and the "commitRequiredOn" method in the DataService class to check if there are pending changes for an entity. However, it seems like "commitRequiredOn" does not check the complete graph of an object, but just the object itself. For now, we have implemented a recursive check on the complete object graph, but this seems like functionality that should come out of the box.
Am I missing something here, or is there just no built-in way to recursively check an entity to see if it's dirty or not?
I can confirm that commitRequiredOn is checking only the objects itself. But there is also the property DataService.commitRequired (and this is checking for all the objects managed by the dataservice) - maybe you can use it.

ResolvedParameter in Unity. Can somebody explain to when to use it?

I am sort of new to Unity all seems to be fine but I am kind of lost when to use
ResolvedParameter in Unity.
Googled and looked on MSDN but still cannot understand when to use it.
Do you have a simple example that could illustrate it's use.
Thanks a lot for your help
You may wish to configure a Type with constructor parameters of a resolved service and a string. In this case you would use ResolvedParameter.
Container.RegisterType<IRepository, Repository>(
new InjectionConstructor(
new ResolvedParameter<IClassifier>(),
"ConnectionString"));
It's for method injection; see Entering Configuration Information on MSDN. Scroll down to "Dynamically Configuring Constructor, Property, and Method Injection" and note that the ResolvedParameter is actually a parameter to the InjectionMethod constructor.
I've never encountered a need to use it. Constructor injection will solve 95% of your issues, and property injection will solve the other 5%. (Caveat: I've only used Unity on a couple of projects, so I don't claim to be an expert.)
As I see it its to be used when you have a constructor where at least one parameter can not be obtained from the container while the rest can. In such a situation you declare how to resolve each ctor parameter when actually creating a new instance of that type.
Container.RegisterSingleton<IConnectionManager, ConnectionManager>(new InjectionConstructor(new ResolvedParameter<INetworkClientFactory>(), Container.Resolve<IBackoffAlgorithm>(), 10));
In my example, the IConnectionManager instance obtains the first parameter from the container (via ResolvedParameter), the 2nd one via Container.Resolve<>, and the 3rd one is a hard-coded integer.
ResolvedParameter should behave equal to a direct Container.Resolve<> but looks a tad cleaner.

Why does Flex's ArrayCollection's Contain method look at memory reference?

When using .contains() on an ArrayCollection in Flex, it will always look at the memory reference. It does not appear to look at an .equals() method or .toString() method or anything overridable. Instead, I need to loop through the ArrayCollection every time and check each individual item until I find what I'm looking for.
Does anyone know why Flex/ActionScript was made this way? Why not provide a way from people to use the contains() method the way they want?
Couldn't you just extend ArrayCollection and override the contains() method? Alternatively you can paste the source for ArrayCollection into an "mx/collections" package in your project and modify the source; this "monkey-patching technique" will override the behavior throughout your entire project. However I would be extremely cautious about changing ArrayCollection in that manner: since it's used all over the place in the Flex APIs there is a good chance you'll start breaking other components in the framework.
The contains() method searches by reference, correct (I believe even for primitives), so if you're trying to find a string or an int in an ArrayCollection, you'll have to do the searching yourself, by some variation of looping or searching. I don't think any of us could tell you why there isn't, say, an optional parameter on that method indicating whether to search by ref or by val, though; so it goes, as they say.
But I'd definitely warn you off monkey-patching the framework code -- that's just asking for trouble. :)
Well, it seems like the ArrayCollection doesn't actually look directly at memory, but only as a last resort. It will attempt to find a Unique ID (UID) for the object. If the UID doesn't exist, it will create one for it using the UIDUtil.as.
You can get around this whole default UID stuff by having your object implement the IUID interface and providing your own UID for the object. The ArrayCollection will look at the UID you provide it.
I would suggest a simple:
in_array($haystack, $arrayCollection->toArray());

Resources