New answers tagged

1

I would recommend you go with the second option: Use Flask for the API and use a javascript framwork like React for the UI component. See seperation concerns (on wiki and stackexchange) for more information about this. The reason for this is that Flask is good for API related tasks and React is good for UI related tasks. Once you start trying to get Flask to ...


1

As I can see it, I have two options. You don't. You only have one. Even if you decide on a full rewrite in a different tech stack, you won't accomplish that if you don't fully understand the old project and its (many, as I understand) quirks. It’s important to remember that when you start from scratch there is absolutely no reason to believe that you are ...


1

The premise of your question is wrong. An ahead-of-time compiled language was introduced in browsers at the same time as JavaScript. Netscape 2.0 was the first browser which supported JavaScript and it introduced support for Java Applets at the same time. But for various reasons Java applets fell out of use. JavaScript was specifically positioned at the time ...


2

Tooling and ease of use. The way the web was done at the time was in a text editor. That is, JavaScript was not feed into a tool that would spit some binary format, because that is not how you develop for the web. Instead, if you develop for the web, you pick a text editor, any text editor, and you type. No special tool required. Well, we have minifier and ...


1

There is no such thing as a "compiled language". Compilation is a property of the compiler (duh!), not the language. Therefore, the term "compiled language" is not even wrong, it is non-sensical. Which makes the answer to your question trivial: you cannot adopt something that doesn't exist. Some people define "compiled language" ...


7

JavaScript was originally used for tiny things. Often, your entire script would be inlined in your HTML onclick attribute. A large use of JavaScript would be two or three functions in the HTML header. I remember thinking why would anyone ever want to use the ability to put a script in a separate file. It makes zero sense to precompile something that small. ...


0

As always, it depends 🙃 If the object you are passing as a parameter (the “options” object) is commonly used across the application, possibly being used to call different functions, the unstructured approach can be useful. However, if you need to create a specific object to call each of the “doLotsOfThings” functions, it probably isn't worth it and just ...


2

So I was musing how can I securely change the value so that it isn't available to poking? In JavaScript, you cannot. However, there is a need to delete sensitive data, so other languages have workarounds. For example, in Java 8 the Destroyable interface was added so that sensitive objects can be cleanly destroyed, but this requires implementation support. ...


0

Everything has its own advantages and disadvantages. React.js is a very popular web framework which is built on top of JavaScript by tech giant Facebook. React is used for big applications in which data changes quite frequently and thus DOM manipulation is quite high. In such cases, React use concept of Virtual DOM which uses a very effective way of ...


0

Yes, as long you are coding with this style consistently and you are not relying on what they are. But in reality no, let's see why. Let me make a short example, you get a Updatable interface public interface Updatable { public void Update(); } Now, there are many things that could get be updated, a sound system, a physics system, another algorithm. ...


0

I think it depends on the example. I love DRY code, but @ScottJacobsen's answer has already made Dave Thomas's point that it's knowledge, not the code itself, that's supposed to go unduplicated. imagine we are in something like JavaScript so that types don't get in the way of my example I take this to mean, "instead of taking a type-A object in my ...


2

They should be separate. A unit of code should have one and only one reason to change (the single responsibility principle). But if your switch statement is being against two unrelated objects A and B, then in the future the switch statement might need to be changed to handle a new use case for one of those objects but not the other. A change to make the ...


18

Your example is a bit too complicated to make your point. You suggest dynamic dispatch, which actually works pretty much like that... if types get in the way and compile-time is a thing, name-mangling helps resolve identification and entity uniqueness. What you describe as accidental polymorphism is only possible at the symbolic level. In the conceptual ...


5

Ever heard of duck typing? Forget what these things “are”. Focus on what they can do for you. If an algorithm needs to call a, b, & c and x, y, & z each have appropriate a, b, & c’s then feel free to use any of them. The typing system was never meant to force you to build elaborate is-a taxonomies to make this work. It sometimes gets taught ...


10

The philosophical question of the day: is it really accidental ? You are telling us as example, that a switch processes events, and that you realise how some of these processing methods have the same name and from there, go for polymorphism. Some people would wonder why all your event handlers don’t have the same name for their methods, and why you don’t ...


1

imagine we are in something like JavaScript so that types don't get in the way *shudder* OK my javascript reservations aside there is a movement to allow "anything that fits a interface to be that interface" even if the type doesn't inherit that interface in typed languages. You'll still get a compile error if you try something that doesn't match the ...


-1

According to R. Martin's "Clean Architecture" everything must have a single responsibility, meaning it has only one reason to change. This is strongly correlated with another principle of clean coding and software engineering - separation of concerns. Therefore if we were to follow these principles, your presentation layer of your domain has to have a ...


1

Returning multiple types (subtypes) is a completely valid approach, in order to represent ok/error behaviour of a method. For statically typed languages, constructs like union type could be used, in JavaScript this is easier, since you can simply return any object from a method. Instead of returning a success/error objects from a method, it's also possible ...


0

The answer is, it depends. It depends on who is supposed to consume the string and what the conventions within the team are. If the string is a message to the end-user, then it it likely that the string needs to be translated. The actual message for the end-user will live in a translation file and in the code you will only have a key for locating that ...


1

I have limited vue.js experience. I will ask a question and answer it for you. Q: why not using "Single File Components"? A: Some components would require very large files and including styles, will make them even larger. As a result of this, readability and maintainability will be getting harder. Q: so what should we do then? A: I suggest you separate ...


1

I personally prefer the first one. but if page and layout are components, it can be nested inside the component folder. style folder in the asset will look like this: global bootstrap material fontawesome app src mixins variables z-admin z-components _form _tag.scss (npm package included and customized) form.scss _page _layout _tool _tostify.scss (...


Top 50 recent answers are included