I am building a robotlegs app where you have to login in order to use it. When you loggin I have numerous mediators,injectors,models,vos etc. What should I remove when one logs out?
Thanks in advance.
This is tough to answer, since your question is kind of vague. Some more details as to the inner structure would be helpful. Depending on your situation, you may just need to remove any navigation elements that would let the user access content that would require them to be logged in. If your user is represented by a persistent object, you could also use an isLoggedIn flag that you would check when the user tries doing something that requires them to be logged in. Again, this is tough to answer because of the question's vagueness, but I don't think there's anything really specific to RobotLegs you need to do, it's more about application design.
There is a onRemove function in the mediator which works like onRegister, it should remove all the registered events in your mediator. Have a look, it may be what you're looking for.
Stephen
Related
There is this site that i have to check every time to see if there is any new available house to rent and i was wondering if it's possible to program a notification for it to not miss my chance. If there is any way to do that please tell me how.
one way is:
You can use python to do that,
you need a Bot (Automation) that will check the availability of the Thing you are looking for, difficulty depends upon the site.
I am writing a REST API. However, one of the requirements is to allow the caller to determine if an action may be performed (so that, for example, a button can be enabled or disabled, etc.)
The action might not be allowed for several reasons - perhaps user permissions, but possibly because, for example, you can't delete a shared object, or you can't create an item with the same name as another item or an array of other business rules.
All the logic to determine if something can be deleted should be determined in the back end, but the front end must show this in the GUI.
I am trying to find the right pattern to use for this in REST, and am coming up a bit short. I could create a parallel API so for every entity endpoint there was an EntityPermissions endpoint, but that seems to be overkill. I could also do something like add an HTTP header that indicates that the request was only to check permisisons, not perform it, but that seems a bit dubious, and likely to mess up the http cache.
Can anyone point me to the common pattern for doing something like this? Does it have a name? Or a web page that discusses it? I'm sure everyone has their own ideas on this (like my dumb ideas) but I this seems to be a common enough requirement that I figure there must be a common pattern for it. But google didn't help much.
There's going to be multiple opinionated answers about this. I'll share mine. Might not be the best for your problem, but it's a valid solutions.
If you followed the real definition of REST, you would be building a hypermedia/HATEOAS-style webservice. Urls would not be hardcoded, they would be discovered and actions would be discovered by the existence of a link.
If an action may not be performed, you can just hide the link. If a user fetches the next resource they just see all the available actions right there.
A popular format for hypermedia API's is HAL. You might decorate the links further with more information from HTTP Link hints.
If this is the first time you heard of hypermedia API's, there might be a bit of a learning curve. The results of learning this can be very beneficial though.
Here's a somewhat general computer question. I've always been able to follow the LOGIC of programming, but when I go to code something, I always find that I don't know some method or another to get what I need to get done. When I see it, I always think, "OF COURSE!".
How do you go about finding relevant methods for your programming needs that are "built-in?" I don't enjoy re-inventing the wheel, but I find it difficult to find what I need to do what I want to do.
First try Google:
You can use google to search your required method. For example If I want to search a value in array in PHP then I go to Google and type "Search values in array in PHP". I find my required function at first place.
Then try Standard Documentation:
Try standard documentation to search for your required method. For example if my problem is related to strings in PHP then I go to String Functions documentation and find the required function.
Finally try Stackoverflow:
Otherwise you can ask your problem at Stackoverflow for your required methods and libraries. You will always get a shortest way.
What you are asking here is for the best way to do research. Well, that's hard skill to explain, even more so to teach.
Nevertheless here are some tips:
Go to a search engine. It makes no
sense to start in a place like MSDN,
since all of its content is indexed
by the search engines anyway.
Phrase your question several
different ways.
As you learn more
about the issue you will learn new
vocabulary about it. Use that new
vocabulary to do even more searches.
If the searches turn out empty,
switch to browsing a specific
section of the official
documentation that you think is the
most related to what you are doing. If nothing else, it will expand your horizons around the issue and give you more vocabulary to do more searches.
Finally, if all else fails ask a question on StackOverflow explaining what you want to do as clearly as possible.
Note that if there's a simple API that does what you need, you will rarely reach step 4.
You say:
It's very frustrating to suddenly find
an "easy" button mid-way through.
Try to see it differently. Think of these moments as blessings. You've just learned something. You invested a lot of effort - and instead of seeing that effort as wasted, see it as critical to proper learning. You - better than the guy who just happened across the magic method - really understand what it's for and something about how it works. And you really, really, understand why you need it, and you properly appreciate its value. You're never going to forget that method.
So it was costly, but you learned something important. Celebrate, and move on.
It is usually included in some form of documentation. Most IDEs support the documentation format and gives you auto-complete functionality.
if you are using MVS so MSDN is really good for it
In addition to this and this answer above, google's basic and advanced searching tips prove very helpful.
In addition to above, changing the order of keywords in search criteria also sorts the list in different orders.
In essence I believe that searching is still an art rather than a science, and is best learnt - quoting from David Reis' answer above: "2. As you learn more about the issue you will learn new vocabulary about it. Use that new vocabulary to do even more searches."
Search in the API documentation. But the best way to (I found so) is to search on the internet for multiple solutions and then choose the one that you think is best. Make your search as narrow as possible. For example you want to implement random number generation function, then search like this, "How to generate random numbers in Java?".
Namespaces, namingconventions, Autocomplete/Intellisence
I assume that you are trying to find some kind of Object-Oriented-apis . I use .net in my example.
First try to find a class that might be responsable for the method you are looking for.
Example: If you want to "Make a new Directory in the Filesystem" you must know (or learn) that (in dotnet) these classes are in the namespace System.IO:
This namespace contains subnamespaces like Compresseion and Classes like File, Path, Directory, ...
Second you sould know NamingConventions. There are common Naming-Prefixes for methods like Get, Set, Insert, Create. In the documentation for class Directory you will find a CreateDirectory-Method.
If you have an intelligent editor that knows your programming language and the classes and namespaces learning is much easier. In the dotnet-world this feature is called Autocomplete/Intellisence
In other words - what would be a good name for a variable that references the currently logged user?
I've come up with a few:
logged_user
visitor
me
I'm not convinced either of them is good enough though.
current_user seems the obvious choice.
The underlying point is worth some elaboration.
It is very important to choose good variable names, where a "good name" has the properties of being
accurate (not sloppily named)
concise (short as possible, without losing meaning)
unambiguous (not easily confused for something else)
If you are stuck then try to describe the thing in plain English.
Do you want to store the name of the user who is currently logged in? How about currentlyLoggedInUser?
In your context do you care about users not logged in?
If not then currentUser would do fine, and it's more concise.
Can it be confused for something else?
Nope. We have a winner!
Now you could shorten it further, like currUser but you lose some of the clarity. Remember the IDE will be there to help you type, so you have to think what you're losing (clarity) as a trade off from what you gain (fewer keystrokes). That point can be settled by personal taste when you're developing by and for yourself, but if you're in a team it's a no-brainer; choose the version that will be easiest to understand in future.
Think of that axe-wielding maniac who has to maintain your code in five years time.
Either theUserWhoLoggedInAFewMinutesBeforeAndWhoHasNotYetLoggedOutAgain or just ich
authenticatedUser, validUser, activeUser, authUser
I would be more inclined to go with the simplest form user. If you need to identify a previously logged on user then previousUser is a logical choice. Also, if you need to distinguish between a user that is logged in or not then a simple isUserLoggedIn boolean will do the trick.
loggedOnUser seems appropriate.
I think currentUser OR loggedInUser seems better.
Terminology: What do you call this type of web gui feature?
I'm trying to research on a gui interaction where the user chooses an option, and the next set of options are loaded based on the previous.
I'm calling it cascading, but that doesn't seem to be right.
Example below:
User chooses company A
company A services load
user chooses service 1
serivce 1 loads, with only options company A wants
...cycle continues...
Silly question probably, but I am tired of getting all these search results that have nothing to do with what I'm after. Thanks in advance for any guidance.
If it matters, I'm thinking of using jquery for this, with C#/asp.net backend. Chose not to include those in the topic tags as I didn't think the language would change the terminology.
I think you're right with cascading if I understand you properly, ASP.Net/AJAX example here:
http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/CascadingDropDown/CascadingDropDown.aspx