New answers tagged

0

To answer your question directly. No, a pure RESTful web service is not required for an angularjs app. It will work just fine with more RPC like interfacing also. I would never recommend anyone to pursue pure RESTfulness, especially the HATEOAS part is just a waste of time and effort. Noone will work with your API that dynamically. Until you have concrete ...


2

In addition to @Jules very good answer: Perhaps you are thinking about the decision making at too low a level. Remember, you are trying to provide a useful and complete abstraction to clients/users/callers. So, one way to frame the question is, do you want clients/callers to have an API that is about: recipes that have some relationship with a ...


4

Let's take a look at your domain: 1) You have Recipes Recipes are a collection of Ingredients and according steps to follow in order to get things done. 2) Ingredients have a name and perhaps a category (»vegetable«, »spice«, »whatever«) I see no place where inheritance comes into play. Does it make sense to refactor to an inheritance hierarchy ...


0

Depending on the language, you don't need an inheritance strategy at all. For example, in Java you would define an interface, in Objective-C you would define a protocol, including all the things that a recipe that you manage would need to be managed, and that other things you might manage in the future would need to be managed. Any new class that you want ...


10

Your option 2 is usually preferred. Option 1 violates the common guideline known as the "Law of Demeter" -- it means that your main program now knows in detail how your Recipe voting works, which makes it harder to change that if you decide to do it another way later. This is an example of unnecessary coupling, which we usually try to minimise.


1

For your applications, create one repository for each. This is so that your commits only relate to changes of that specific application. This will allow you to keep better track of your versions. For your Data Structures, perhaps you could create one repository for all of them (and consider that repository a "foundational component" library).


1

I have little mathematical background but I do see an approach that might work. I would assign a value to each coordinate in the grid that is determined by the amount and closeness of dotted neighbors. Then apply a threshold: only keep the coordinates that exceed the threshold value. Those will form the result path.


0

I believe you missed a point here, your Aggregate root should be your Test Entity. And if it's really the case I believe a TestFactory would be best suited to answer your problem. You would delegate the Question and Answer building to the Factory and therefore you could basically use any solution you thought of without corrupting your model because you ...


0

Possibly the most efficient way is to store all the tasks by their filter keys, so you'd keep track of key1 and associate task1 and task5 with it. You can then iterate through each input key to add the set of tasks for that key to a result set and then count the number of times each task appears in the results. For each task that appears the number of times ...


13

You can always add a file into your project and set its build type to Embedded Resource so that it is embedded directly into the application itself. Alternatively a file that is encrypted and placed in an accessible location.


21

If the data never changes and is read only, then just put it in a code file as a list of constants. public readonly string AppStartUpData = "MyAppNeedsThis"; If this data is different per deployment, then an external file is fine. .Net comes with built in .config files (App.Config). One should use those as there are standard ways (built in to the ...


11

A binary file would be the obvious answer, but it depends on how you are loading it - you might as well make life easy for yourself if you can. XML might be a good choice as there are built in methods in C# for reading this. You could add a checksum to your data, so that if the user alters it, the checksum will no longer match (you need to add a check to ...


6

If you don't want the user to even peek at the data, you should serialize it into a binary data file. Only the app would know the length of the chunks to read from it. I don't know C# but in Java you would create the file like this: FileOutputStream fos = new FileOutputStream(file); ObjectOutputStream oos = new ObjectOutputStream(fos); oos....


1

Optional parameters can work nicely here. public class Vector { public static readonly double DefaultTolerance = 0.0001; // or whatever. public bool Equals(Vector other, double? tolerance = null) { tolerance = tolerance ?? DefaultTolerance; // go about your business } } // later w.Equals(v); w.Equals(v, 0.001); And since the tolerance ...


10

We've had a few problems where a contractor changed something in a common project and unknowingly this breaks a number of other solutions That's is unfortunate We're currently trying to decide a new software architecture in our company STOP. You have a process problem, not an architecture problem. A much simpler, and more valuable, fix to this ...


1

To put all the applications in one solution is to say that all of the applications are related somehow. If they aren't, don't put them in the same solution. What you really are after is code-reuse. Since you don't specify a technology stack I'll list out some options in multiple technologies. These allow you to share code without stuffing applications ...


4

But I know that throughout my application, the tolerance will be constant. This is a bit suspect because such tolerance is usually very algorithm specific. I've had to deal with much pain because someone thought that it they could get away with using a constant tolerance everywhere. But assuming, that you really do want this, I might do: public class ...


3

Onion architecture is one of the possible choices when you use DDD. If you decide to use it, the implementation should be in the infrastructure layer. You can have several implementation of the same interface and inject the required one in your application. IMO the interfaces themselves should be in the Domain layer.


1

Depends on what your interface returns. Assuming they return domain entities they should go in your domain layer. The actual interface implementations can go in your persistence layer. When you have your repository interfaces in the domain layer the layers above does not depend on your persistence layer. From a conceptual standpoint the idea that you get "...


0

I decided that it is better to add a single WebJob per Topic and have individual classes that handle each subscription. This gives a self contained application, that find a balance between ease of maintenance and ease to update and deploy.


3

You are trying to create a layered design. In the top layer are inputs & outputs that interact with the elevator riders: the inputs are the button panel in the elevator and the displays of what floor it's on along with the up/down indicator and button pressed indicators. Further there are up/down call buttons on each floor (and a duplication of the ...


0

Rather than doing the calculations by hand it might be beneficial (depending on the complexity of the queries of course) to use an OLAP server. Some OLAP servers support creating MOLAP or HOLAP cubes that have pre-calculated aggregates that will improve your query performance significantly (E.g http://kylin.apache.org/).


0

PostgreSQL would be slightly better, because its design leans more towards analytical workload, unlike MySQL which was designed for transactional workload. That is if you want to do the calculations directly in the database. Getting player statistics is analysis of the data. The obvious drawback (while not really that important) of PostgreSQL is its lesser ...


0

If I understand well your design, the general idea of the interaction between the parts of your system would look somewhat like this: So you are using tags for 2 purposes: let the server know if the request is to be parsed (no tag) or if the request was parsed and provides parameters to be extracted (tag indicating a command/transaction to perform) ...


2

I would go for the clone method if the class involved was polymorphic (so that an instance of the right runtime type was created). Otherwise it's a matter of taste in my opinion.


2

Many other good answers have been written, I just want to add a short point. The traditional answer, especially when the ISO C++ FAQ was written, mainly compares "C++ exception" vs. "C-style return code". A third option, "return some type of composite value, e.g. a struct or union, or nowadays, boost::variant or the (proposed) std::expected, isn't ...


2

The first thing to realize is that the situation you describe (some items are 'never' processed) can only arise if you simply don't have the capacity to handle the volume of requests. If you have the capacity to handle the expected volume of requests over a given time period, you will be able to handle all the requests. This is a tautology. Changing the ...


3

Use copy constructors. Here's why: IClonable semantics are ambiguous. Microsoft never specified whether a clone should be a shallow or deep copy. You can specify custom behavior in your copy constructor, such as giving each copy its own unique ID or only copying some fields and not others. Further Reading Copy constructor vs Clone in C#


0

With respect to modifying records when the user presses "ok" in the dialog, you must compare it with the database record instance. You cannot rely on cloning the original HTTP get because someone may have modified the record before you and you get race conditions. If this is not the case, this has been covered by another thread and I am hoping it helps you ...


-1

Can anyone help in deciding how do I uniform these two through a single interface having two implementation? Or are they not meant to be uniformed via a single interface and deserve a separate way of implementation? In short, Interface Segregation principle is important because if a certain class becomes the new hotness then one would want to use it ...


1

You can look to the W3C specifications as an example. They describe a small syntax of their own which means you can implement the HTML5 spec in any language: https://www.w3.org/TR/html5/ Another good example to look at are descriptions of algorithms and data structures which have a small syntax of only necessary components and leave the implementation ...


6

The scheduling mechanism you have described is Fixed-priority pre-emptive scheduling. If you know there is a possibility the max priority queue is always full, then you are using the wrong mechanism, because of starvation as you described. You could prevent starvation by using a different scheduler. For instance, you can say that you process at most f(...


3

Basically you're making priority a function of two variables, like pricePaid*A + waitingTime*B. That's a perfectly sensible strategy. Suppose you're selling tickets, and the price people pay puts them into one of the queues - high, medium, low. You could look at that as a single ordered priority queue, where the priority is high, medium, or low. Within each ...


0

You have 10K posts and 30K comments and you are primarily scrapping this data for better searching capability. First things first : SQL is not good for natural query searching for example if someone searches for "Which college is good" it tries to search for the exact string from you SQL and it might not match any of the records. I would suggest you to ...


0

However your organise it, the important thing is to have a standard. Personally, I like putting them close to the top of the file, directly below public types, and above internal functions, but this layout wouldn't be logical with the one you're already using (which puts a higher level function at the bottom of the file) so perhaps you could try inverting ...


1

Don't get too caught up with the way things are usually done, an API can be restful without having to have resource identifier specified in the URL. In your case I would say its perfectly acceptable to place the path(s) in the POST body.


0

I may want to google for the term "ABAC" (Access based access control) Definition (wikipedia): Attribute-based access control (ABAC) defines an access control paradigm whereby access rights are granted to users through the use of policies which combine attributes together. The policies can use any type of attributes (user attributes, resource attributes, ...


0

Here is how I would approach the situation: You keep your Users table What you consider as Roles are, basically, groups of Users. So, we create a new table Groups What you call PermissionLevel is the equivalent to Roles that members of Groups can have (eg. a user who is Tech_Admin can have the role of Tech_Account and Non_Tech_account I would replace the ...


1

First, as others have stated, things are not that clear cut in C++, IMHO mostly because the requirements and restraints are somewhat more varied in C++ than other languages, esp. C# and Java, that have "similar" exception issues. I'll expose on the std::stof example: passing an empty string to std::stof (will throw invalid_argument) not a programming ...


1

Here is my take on this : The requirement is to find out the sleeping activity of the user ids that are stored in MongoDB which can grow till 1 Million. Later this requirement can be extended to pull other activities of the user. To build a decoupled scalable system, you can create 2 services. Service 1 : picks up the userIds from mongoDB or other ...


1

Your current design is this: You should ask yourself: does entity PERMISSION_LEVEL represent actual levels? Is they are actual levels it means that when a user is granted two different roles and both roles have the same command but with different levels, the app should take the highest level of them. In role-permission models with no permission level, ...


2

I would decouple the three responsibilities for a repository (load book from XML, load book from a database, cache book) into three different implementations: public interface BookRepository { Book getBookFromId(string id); } public sealed class XmlBookRepository : BookRepository { private readonly string path; public XmlBookRepository(string ...


2

This would be a good use for a producer/consumer setup. Without going into the implementation in detail, you'd have one component whose job it is to pull the list of users from the DB and add them all to a queue. This could be triggered by your timer. Then, you'd have a component which sits there in a loop pulling an item from the queue, making the API ...


1

Does this look like a reasonable design for Role and Permission management ? The term "reasonable" is somewhat ambiguous here. Fit for purpose This design achieves it's purpose. It enables to determine what operations any logged-in user can do on any specific business object : Users are identified Roles are identified Users are assigned to roles ...


2

Well there is no generic answer, for some it's a matter of opinion so i won't answer in a generic way but i'll take your points one by one. I'm answering considering that all of those will be designed as simple interface. Not implementation. a web service that downloads a PDF of a SQL Server Reporting Services (SSRS) report. This could be just part ...


2

Okay... a simple answer. When I'm building a project that has 'perpendicular' behavior (connecting to external systems, writing to log files, etc) I do it through a library and generally make the calls to it in the business layer. The business layer typically is where the action requiring external access is taking place, and by building the capability into a ...


0

I understand your concern that you want to keep JS code to bare minimum and rely on HTML and plain HTTP for all server calls. If your purpose is solved by doing so you can well keep out of AJAX. But it will be wrong to say that AJAX is useful only in content rich environments. Asynchronous requests not only provide a faster User Experience but are useful ...


1

This is a highly subjective issue, as it is part of design. And because design is basically art, I prefer to discuss these things instead of debate (I'm not saying you are debating). For me, exceptional cases are of two kinds - those that deal with resources and those that deal with critical operations. What can be considered critical depends on the problem ...


2

From the Design by Contract perspective, define the preconditions and postconditions of the function, and any class invariants, which specify the contract between different parts of the system. This makes clear the responsibilities of the function and its caller. Define the action (which can be throwing an exception), to be taken on violation of the contract,...


-2

Yes it is. AJAX requests the HTTP too, but what's the best you can do it without reloading page. In example a system where you need to delete single users one-by-one it's more effective to delete them without reloading page, because you don't have to wait until page is loaded when choosing more users to delete. AJAX is more user-friendly.



Top 50 recent answers are included