Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am a .net developer by trade. While I wait for Microsoft to ease up on constantly reinventing the v.next. I thought I would have a look at nodejs. I have worked through a number of small tutorials and it seems to be going smoothly.
One thing I am having trouble with is understanding what data is being passed around and how to read function headers. I would imagine this is because it is a dynamic language (Javascript) were as all my experience has been in static languages.
Are there any tutorials / other, that talk about this portion of development, that is the structure of nodejs / Javascript which would make it more clear how to develop correctly in a dynamic language?
First of all it is good to know that almost every Node API follows the same convention for registering callbacks, calling them and passing around errors and data. For example...
fs.readFile(path, function (err, data) {
if (err) { throw err; }
// Do something with the data
console.log("Data is a buffer", data);
console.log("Data as a string", data.toString());
});
What you see in this example is that the first param of the callback is always an error object and the subsequent parameters contain the data.
If you want to know what kind of data you will get you need to check the documentation of a given API. This can be the found in the Node.JS Docs or the documentation of the module that you are using.
Node modules are an important aspect in NodeJS for structuring, abstracting and isolating your code. Every module provides a clear boundary between the implementation and the user. Isaac Z. Schlueter (creator of the Node Package Manager) wrote a nice article on building modules.
The best way to learn node is to look at other people's modules. Because most of them are written in pure JavaScript you can open up the code and see the implementation.
There are also a lot of good videos to watch...
Watch the Joyent's NodeCamp videos
Felix Geisendörfer - Node.js in production
Rob Conery - Real World NodeJS - Creating the Tekpub API
Let me know if you want know more specific things about node where I can help you with.
Related
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
The e-commerce site would include a booking system also and other variables other than just selling and buying goods.
Sadly, there is no simple answer, but, that also means more variety of languages to choose from, you can do anything with almost every programming language, but, each one has its strong points and weak points; In my opinion, heading for the most popular is the best choice to opt to, given a few reasons:
It is easier to find tutorials and answers to your questions, as they will most likely have big communities.
They're popular for a reason, as they are most likely best suited for web development.
Some of these languages are Javascript, Python & PHP — for quite a few reasons, but, as to my personal opinion, I think JS dominates the web development market.
First, to start-off, JS or Javascript is a high-level, medium difficulty language, a scripting language(it is also, OOP(Object-Oriented-Programming) language, but, it is really not, as it is just an illusion.); Javascript is the dynamic life of the web, Javascript does anything from animations, events and et cetera to HTTP requests, fetching, I/O intensive work and it is the most used language in the web!
Javascript has some sugary syntax, so, it is not hard to read and also, it can do absolutely anything from OOP to Dynamic programming and on top of that, it has the 2nd largest community as of now.
But, there is one flaw with it, it is a single-threaded language, so, it only works as one bartender in a whole bar with thousands of people, but, that bartender works at the speed of light, it doesn't wait until the drink becomes ready, but, rather queue up orders and hand them out in the same order, but, it will only take orders and not execute them until the first one does and the second one, the third one and so on, so forth; therefore, it is prone to be blocked and if that happens, your whole site becomes unresponsive, but, that could be fixed pretty easily and with a few good practices, you will be safe; so, don't get discouraged by this, JS is really powerful and one con against all of these pros isn't really significant, but rather, negligible.
Python or PY is more suited for process-intensive stuff (i.e. calculations), so, if your site has some math in it, then, Python would be the choice to go for; also, python is rather good in managing data, analyzing it and et cetera, that is why it is being used in almost any data-science infrastructure; also, Python is very user-friendly, very easy to learn and read, also, it has the biggest community that you can find. (Also, Python has the shortest syntax that you can find.)
This was both languages in a nutshell, but, you have to know that Python isn't really good at optimizing hardware, so, it will drain the hardware, but, JS (and its back-end framework — Node.js) are very good at RAM optimization and ALSO, JS is said to be 75 times faster than Python, so, there is that.
Both languages have their back-end frameworks like Node.js and Django(for PY), but, Python can't be used in the front-end, which is a down-side, but, not really a big deal.
Also, you have to know that you can now, code with any programming language on the web, using something called Web Assembly, it changes any programming language into JS, so, it could be understood by the browser, but, that is a very broad topic and I don't suggest using Web Assembly, as you have to learn new things and it is only good for a couple of small things and E-commerce ain't one of them.
So, to end this off, JS & PY are the pretty strong and best choices to make when it comes to E-commerce, but, you'll probably need a few more things like query languages for databases(like SQL) and an actual database like MongoDB or Firebase, but, that choice is up to you.
ALSO NOTE: JS has front-end frameworks & Libraries like React.js(A view library) and Angular.js(A framework) and Vue.js which is best suited for light-weight projects.
Hopefully, I helped you to make a choice about your site, and please, don't use CMS as you'll be supporting the CMS community which is trying to kill the programming community (which will never happen), and also, you can't call yourself a developer if you use them only and don't code at all. (Yes, they are easier and save time, but, not the best nor optimal solution as they restrict you.)
"Programming isn't about what you know; it's about what you can figure out.” - Chris Pine.
It really depends on "how" you want to make it and "when" you want it, and as a programming language just pick the one you're familiar with and can do the stuff for you. Don't choose a low-level language like C because it will be really painful to make a website using it.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm very beginner for unit testing in node.js, I want to know what is the best practice of writing unit testing in node.js for example 'it' method how many assert test cases I can have, Is there any standard of writing only one test case in single it method. Please give me an idea to write the unit test case.
Thanks in advance.:)
Test one part of functionality in one it() call and only use multiple assertions if really needed.
If you use 2 assertions in one it() call, failure of the first one will block the second one from being executed, thus hiding part of your tests and therefore preventing you from getting a full view on a possible error.
Study how to use before/after and beforeEach/afterEach inside a describe block - those will really help you to only perform tests on small parts of your code in every it(). See the 'Hooks' chapter in the mocha documentation.
Optionally create your own set of helper functions to prepare set up your code for a single test to prevent (too much) code duplication in your tests - I believe code duplication in tests is just as bad as code duplication in your 'real' code.
This free tutorial explains Chai and Mocha quite well, and how to structure it.
While Mocha is a regular test framework, Chai is an expectation framework. The key difference is syntactically sugary how tests are formulated (the use of it() for test cases), which I personally find confusing, too.
For a starter, you should probably stick with mocha. It might help you to get some wording straight:
Mocha is a test framework (so you have a defined outer set of functionality, in which to fill in the gaps, aka place your tests, etc), whereas
Unit.js is a test library, so it offers a bunch of functions (like all kind of asserts), but you are driving your script. (No test suites, test rnning)
The mocha.js framework uses the unit.js test functions (see here).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
My question is really very important .
When i program i have seen that i had lots of errors in programming logic + structure + a flexible when it goes for testing , i have read many books on OOPS and my all the concept are clear but i do not know where to start design of my code or project . can any body help me how to improve this part of programming skill.
although i work on php+javascript but this question is for all the programmers on stackoverflow
note- usually when i hold paper and pen i think where to start from ..
if i make something problem is how to simplyfy.... and many others which u all are facing / faced
Well, I think everyone is different as is every project. But here is what I personally do...
For my own projects, i.e. no client requirements, I start at one end or the other, either with the database structure or the UI. I then work down through the layers making sure that I maintain clear separation of concerns to make testing (unit and system) as well as maintenance as easy as possible.
One thing to note is that regardless of your approach I think the process is iterative. I will often work, refactor, work, refactor etc so don't get too bogged down with the details and feel you have to stick to them. The requirements are the key thing (whether for yourself or for a client), the technical implementation is largely irrespective.
When dealing with clients the process is somewhat different. You will need to do a fair amount of design up front so again think from one layer to the next trying to keep as much of the logic in the correct layers as possible. As an example you have your DB, then you want a data access layer (DAL) to abstract your code from the DB access. Then you want specific business logic libraries which use the DAL, this abstracts the higher portions of code from the data (they go through the business layer) etc etc.
Just think of each level and try and keep it as generic as possible, that way when you wish to change the storage for the data, you simply change the DAL and everything else works as before...
As far as starting a design of your project is concerned, whole lot depends on what you are developing, that is requirement of the application. So first thing is that you must collect information about the purpose of your application. And when we start to program, a plain trend must be kept in mind, which is, as a universal fact of programming, Input-Process-Output. So, design starts with input. Just collect as much information as you can about what will be required as your input of application. If the input is not made by your user, than it is not required to be mentioned in your front-end design (In Windows language, the so called "Form"). What user will give, is matter of concern in designing the input area (very first step to start project).
During the designing phase, constant interaction is required with user to make effective & flexible start design, as ultimately he/she is going to use. If I'm starting a project's designing, I always consider the user a lazy person, if we keep that thing in mind, our application will be simpler & easy to use. Once, you'll kick-off the start, its just a flow, that'll suggest you next step.
Hope this helps............. :-)
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
Can anyone please tell me, in what order we've to learn languages?
1.(X)HTML
2.CSS
3.JS, HTML DOM, jQuery (client-side)
4.SQL
5.PHP & MySQL (server-side)
6.Ajax
Am I correct? Is it good to learn "jQuery" before learning PHP & MySQL, SQL, Ajax?
(X)HTML
CSS
(any server side language you want)
(whatever database language you want)
JavaScript
(any javascript library you want)
To summarize. First learn structure, then learn style, then learn the backend languages (and their databases) and then learn JS and whatever library you want with it.
Learn as your projects warrant, You can't learn everything so start with what you're being asked to do and branch out when you find things you enjoy.
You're a bit confused. Neither jQuery nor "HTML DOM" nor MySQL are languages. More importantly, there is not really a fixed order, though certain combinations (e.g. HTML + CSS + JS) are obviously more helpful than others (CSS + SQL).
IMHO, first you need to learn HTTP protocol to understand how those things work. Only then you can begin with pure HTML and JavaScript. Then serverside programming: PHP or whatever language you will like.
Frameworks must be learnt AFTER the basic knowledge of those technologies.
It depend on what you need to work on. If you are only working on front-end you can will need HTML + CSS + JS. IF you are working on back-end and dynamic page generation you will need to learn a server-side stack (i.e. PHP + MySQL or ASP.NET + SQLServer).
I started from the back-end coding and move through to learning HTML + CSS + JS
You're better off with Python instead of PHP if you want to become a programmer, not just crank out sites badly enough.
What's the point of knowing SQL before server-side programming?
XHTML can be dropped altogether or pushed down.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
In a related question, I asked about Web Development. I came across something called OpenLaszlo yesterday and thought it looked interesting for doing some website development. The site has a bunch of good information on it and they've got some nice tutorials and such, but being a total novice (as far as web development goes), I'm wondering whether anyone here would recommend this. As I stated in my other question, this is a new world for me and there are a lot of directions I could go. Can you compare/contrast this and other web development you've done? Obviously, this is somewhat subjective, but I haven't heard much about it on SO and I'm hoping to get some opinions on this.
I worked on a website for about a year in which the entire UI was developed in Laszlo. I've also developed AJAX applications using JS frameworks such as JQuery, Prototype and Scriptaculous.
In my experience, the total effort required is considerably less when using Laszlo, and the class-based object model helps to keep your code better organised than when using JS frameworks. My only complaints about Laszlo were that:
It "breaks the browser" in terms of support for the back/forward/refresh buttons. This problem also exists with AJAX, but most JS libraries seem to have found a workaround.
No support for internationalization, though none of the JS libraries are any better in my experience
Relatively small user base/community compared to competitors such as GWT, JQuery, etc.
All in all, I thought OpenLaszlo was a pretty good solution for creating rich web-based user interfaces, and has a number of very novel features, e.g. ability to deploy on multiple runtimes (Flash, DHTML, etc.) without requiring any code changes.
Also, I should mention that I haven't used it for almost a year, so it's likely that some progress has been made in recent times on the issues I mentioned above.
Update
5 years since I posted this answer, things have changed considerably. In case anyone is in any doubt, don't use Laszlo, the project is completely moribund.
I used openLaszlo to develop a few blog widgets for some friends of mine (about a year ago) and it was easy enough to get something basic working and it looked OK. But if I had to do it again, I would probably use FLEX I think you can make a more polished looking application in a lot less time using Flex than with Laszlo
You definitely can write a flash app quickly with OpenLaszlo. There are a lot of similarities to developing for Silverlight.
One OpenLaszlo lameness is that it uses a lame variation of javascript similar to ActionScript. Takes a little getting used to, if you are used to the latest features.
Also, the final flash file that you end up with is very large (file size) compared to what you can do with other tools.
One benefit of OpenLaszlo is the possibility of DHTML output. But for me the mix of XML and JavaScript in the same source file was somewhat confusing.