Today me and my team analyzing excel sheet and try to evaluate the its architecture. For resolving the sequence of its formula, I believe they used command pattern with chain of responsibility design pattern for ordering of formula execution. The only thing I want to understand is how excel maintain the sequence of formula execution as one formula cell(f1) can be used as input in another formula cell(f2), so f1 has to execute first before f2 and there should not be a cyclic dependency in all formula. Any help will be appreciated.
jeudi 2 mars 2017
MVP and Android Handling Lifecycle events, where to do UI logic
I am converting my application to use the MVP pattern. There is some debate between the developers on the proper use of MVP especially in regards to the Android lifecycle and where the UI related logic goes. There is no debate that any hard logic should be done in the presenter, and that the network
In the case I need to do Anything for lifecycle functions, onresume, onPause, etc. Should I ...
- Call a mPresenter.onResumeEvent(); The presenter then does calls. IE contract.restoreState(); contract.connectToService() etc.
or
- Do all the logic I need here and not involve the controller. IE restoreState, start up loading spinners, etc.
I view it as onResume is an event. All events should be processed by the Presenter. The counter arguments is, we do not want to write code that "ping pongs," I.E. OnResume -> Presenter -> one line function that shows a spinner (or something close to that effect)
Now a bit more granule. Lets says I start my activity, and I need to show either an error or the data depending if the data is null.
I could either do..
(presenter)
contract.setupUi(data);
then
(view)
setupUi(Object data){
if(data != null){
//show data
}
else{
//show error
}
Which has the UI controlling the state evoked from the presenter.
Or I could do
(presenter)
if(data != null){
contract.showUI(data);
}
else{
contract.showError();
}
Which has the contract looking at all the states.
Is the over all goal to have the Presenter Completely control everything about the application and treat the view as completely Dumb. Or is it just dividing up the code purely for testing purposes. Or is it both?
Recap.
- How should I handle the lifecycle -- treat it as an event or let the view just do it.
- Where should the view related logic go? Let the Presenter figure out what is null and what UI to show. Or let the view take care of it?
- What should my over all focus be? Controlling the app with the presenter, unit testing, both?
How to combine Abstract factory and builder design patterns
I am trying create the below User Interface by combining Abstract Factory and Builder design patterns.I am facing difficulty in implementing it.Can someone help?. aenter image description here
jQuery DataTable API structure - confused with javaScript code
I have some task to solve with jquery DataTables we use on our application. I need to add a feature, the DataTables currently seems not have. To build this feature I tried to debug to understand framework structure and often confused, because while call a method it often lends to function with different name and arguments structure. Why this happen? Here sample: Here call to put data in table
Step into in debugger and I get to confusing place:
- I get in anonymous function instead of add method called. This could be if add method was assigned with this anonymous method. Right?
- Why it takes two arguments? Why data.data argument appears on second place instead of first? I know javaScript allows to use different arguments number in method but what about change argument place?
- The anonymous function I'm currently in, returned from outer wrapper function which assigned to methodScoping variable. Why to wrap in this manner and return?
May be here used some design pattern I cannot identify. Please help.
Regex quantifier with capturing group issue
whats up?
I'm trying to get some regex to work, but I'm facing some "weird" (?) behaviour.
I need a regex that validates the following:
- Only numbers (no whitespaces at all)
- Starts with 10 or 11
- Max 12 characters
After working for a while on this I'm stuck with this:
^(10|11)[0-9]{10}$
It seems to be working as desired, but I'm not satisfied since it's misleading at first glance. Must be 12 max characters but it validates max 10 + the 'starts with' characters.
Anyone have a better solution or care to explain why this is happening?
Thanks in advance (:
A factory is a class that **creates** instances of another class. What is a class that **modifies** instances of another class?
A factory is a class that creates instances of another class. What is a class that modifies instances of another class?
For example a factory can look like this:
interface PenFactory {
Pen createPen(Ink ink);
}
I have a class that looks like this:
interface PenWhatToNameThis {
Pen refillInk(Pen pen);
}
Does this kind of class have a name similar to factory? I am considering something like mutator or modifier.
Further optional info
I am using these two classes for testing where I need to create and sometimes modify Pens. I could merge both classes into a single class called PenUtils but I like to be able to group all of my Pen creation methods together.
Java Regular Expression (Regex) , match this sequence
I need to match this sequence of characters. Any number of alphabetical characters or /< but not /
For example these strings should match
Mary<Jane<<hello
Mary<<Hello<<Hi
Mary<Jane<<Hello<HI
These shouldnt:
Mary<<jane<<hello (only once can there be /</< together)
Mary<Hello<hi (There isn't a two together /</<)
I've tried a lot of things. I cant figure out why this wouldnt work:
[A-Z]+[[[\<(?!\<)][[A-Z]+]]*][\<][\<][A-Z]+[[[\<(?!\<)][[A-Z]+]]*]