I'm working on a WPF app hitting SQL through a Web API.
What's the right way to handle a concurrency violation? Do I need to check the timestamp myself in my DAL's update methods? Or will SQL throw an exception? If I have to check it myself, is throwing an exception the best way? What exception(s) are used for this?
What I'm really interested in here is the full workflow from the time the user clicks Save to either the data is saved or a violation is handled in the front end?
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
Yes, since you do not know wheter the old record has been modified, or even still there. Would obviously not be happening often, since mostly there's not a lot of people working on the same record at the same moment.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
"If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.
I've read the docs and it seems that processes writing to a single log file requires socket implementation. Really? is it not possible to create a static singelton class and logger instance, in a module, and import that single instance object into each module as the logger and use that? In either case, how might this be done simply and without extravagance.
Hi everybody. I have a question about Memento pattern.
Let's suppose we have a class which's state has to be saved and later restored, and we resorted to the Memento pattern for that.
What if the state includes resources that have to be explicitly released (like file handles, OpenGL textures etc)?
Should I make them part of the saved state? This necessitates to handle memento objects in a special manner: if memento was restored, then it's up to the originator class to handle the resources, if memento is dropped, then it has to clean up itself. Pretty entangled logic.
How would you implement Memento when state has resources to be released?
Should I apply Memento at all when object state includes OS resources that have to be released?
You "save" things that may change. You don't simply save "everything" related to an object instance; things like "resources" are usually "common" to the class / assembly and are not "saved" for each object.
"Saving" is independent of any "cleaning up" you do "after" saving (key data).
"(I) am amazed to see myself here rather than there ... now rather than then".
― Blaise Pascal
Keep in mind that a resource that needs to be released is, by definition, an object, and is therefore tracked by your object as a memory reference.
This should inform the design decisions made on your originator. Do not use handles to track files, use paths. Do not load a texture into the originator; apply a method for locating a texture based on a primitive type. Don't contain streams in the originator, instead contain values that will help re-initialize them.
A lot of these issues are a big part of the reason why Model classes and MVC-like patterns have come into such heavy use in recent years.
"Never attribute to malice that which can be explained by stupidity."
- Hanlon's Razor
So I have this design in Python2.7. Basically it is an EPG app that can read EPG programme events from 1 or more XMLTV sources. I would like to be able to use a generic code base and switch-in the XMLTV parsing code. For example, in 'C' I can use:
// Make call to external xmltv function declared in .h file (above)
// and defined in an external module compiled in using a Makefile
So what i can do here is define the preprocessor macros (_XMLTV_*) at make time, use the compiler directives to pull in the appropriate definitions for the desired xmltv parser, and switch in the corresponding source/object module (rytec.c/rytec.o and bbc.c/bbc.o) using the Makefile. Here for example, if XMLTV is not defined outside the Makefile at build (i.e. command line option) then the default rytec module is built in.