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
When learning/working with a new API, does anyone have any tips for effectively learning it?
I currently make a bunch of get requests to understand what I can and cannot retrieve based on the API's responses. From that point I try to map out what is within the API and see what I can build out.
If you guys could share anything what you do that would be great.
The first thing i do is to read API documentation and search for examples in it. As you get used to read this kind of docs you'll find easier to find exactly what parts of the functionality you need to learn first.
I also use search engines to look for more working examples, and after that I work on creating a minimal use case of the API (for example write a file with commons-io api of apache). For this is a good idea to create a project with multiple JUnit tests with minimal use cases of an API (in the example of commons-io create a file, delete a file, move a file, copy a file, ...).
I must say this is not a science and each API is a new world and may require a slightly differnt approach (As with rest apis you'll need to use some tool like curl or postman to understand how to communicate with them, others will have pre-requirements like have a working installation of a system, and so on).
As everything in coding you'll need to do it by yourself and struggle to solve issues you'll find by yourself (what can take several hours of your free time).
There is no "magic" behind learning something, and coding is in some way like playing a musical instrument, it requires practice.
I dont know whether you are a beginner or you have developed already but will start from scratch..!!
Apis are the code which will allow you to play with the content having certain formats...!!
There are apis based on what operations you want to do are.
Get=> In order to fetch something.
Post=> In order to save something.
Put => to update something.
Delete => to delete something.
People also use patch similar to update...!!
You can play around all these by constructing objects and databases...!!
You will require rest services spring restful web service is the ultimate good options..!!
Diving deeper you need to be careful assigning the names you give I mean the meaningful names as you dont know if tomorrow you become famous and need to make your apis sharable ;)
Now some common concerns are like
Meaningful Name.
Versioning is required like what the old apis are working and now what data your apis give.
Can implement swagger its a tool which will allow you to describe the apis like you can write what this api does what type of data it brings etc etc..!!
Apis are more or less called an end points means you have that link as a connection between front end and backend So need to keep it secure..!! By authentication.
Above four points are considered to be good practises for writing apis ;)
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 6 years ago.
Improve this question
A relative of mine wants me to to make a program to organize some information at where she works. It's fairly simple, however I don't know what kind of office drama they have going on, but she doesn't want to bother IT with all sorts of questions about the database that can be used, how it will connect (multiple people will read info stored in a database of some sort hosted within the companies intranet).
Anyways, I'm thinking it shouldn't be a problem to just use something like a local Microsoft access database file for now, and then rewrite the database component when I have more information. Is that an insane idea? This program is not hard, it can probably be written and tested in a week if I was working on it full time (I'm still in college). For that matter, I am thinking of using Java in Netbeans simply because I am comfortable with it. Should I worry that I find out they use some sort of database or other solution that cannot be (easily) worked with in Java?
While knowing a requirement like database type upfront is a good idea, being able to adapt to new requirements is a part of Agile development.
I'd argue it's not an insane idea. If you're careful about your design, switching out database won't be too bad. If you don't mind, I'll elaborate on a (possible) pattern that might save you trouble.
Overview
In my experience I have found it best to abstract the database logic (how to communicate) from the business logic (how to accomplish a task). These two layers are going to make your code much more maintainable for when you find out the company is running an Oracle database and not Access.
Data Access Layer
The DAL has one job and that is to communicate to the database. It needs to read, it needs to write, and that is it. Your classes will likely include information like table attribute names or queries. It's OK to do that here since the class is specific to a particular database. Using a DAL will greatly simply your database calls later on.
I would highly suggest looking into factory pattern for how to design these classes. Using factory pattern will completely decouple the Business Layer from the database specific classes using interfaces. In other words, you can completely change out the database without needing to modify the business logic.
Business Layer
In fancy terms, all I'm talking about is the logic for how to accomplish a task. The business layer doesn't have anything to do with where buttons appear on a screen nor should it worry about table names.
In this layer you will find yourself needing access to the database to read/write information and that is when you call on your Data Access Layer. It will handle the ugly details keeping your business logic from having to know what type of database your are using.
Data Transfer Object
Lastly, you're going to be pushing a lot of information between these layers. I suggest you design some classes that can help you transfer data that belongs together. Consider a call to the DAL requesting a book...
Book book = libraryAccessObject.getBookById("ABC123.45");
Getting a book is going to return a lot of information. Creating a book object to organize that information will make life easier.
In summary, it's not a far fetched idea but be careful with your design. Poor deign now could cause you a lot of problems next week. Layering your code will make it much more maintainable.
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 have to submit a project in my college for which I have only two months! I already have an idea of what to make but don't know which technology to go for. I want to use something latest so as to make my project more efficient and flexible.
I wanted to make something like "Attendance Management System" in which we can take attendance of students and save the records on underlying database, also to perform some kind of data mining on the data (to find some interesting patterns like the_most_attended_lecture or to apply some probabilistic model to estimate the_next_possible_bunk or analysis based on an individual student record to compute anything interesting...) and then to develop an android app for the UI that can handle request and response to the database.
I'm really confused as what to go for? Currently I have no knowledge of the following but my friend suggested me to choose among them: node.js (with express framework) REST API, PHP, JSP, JSON, and MongoDB.
I would really appreciate your help guys. Please help. Thanks
Lets try to decide the technology stack according to your requirements.
1. Latest technology - Although you didn't give any justification for this requirement. But as you want, latest fads going on are for web server are node, go lang, nginx(if you happen to choose php in the end) and mongo, elastic search for data store.
2. Less amount of time - You have only 2 months to learn the technology, build the prototype , design the db schema, implement everything and test. Hence I will suggest you to go with node.js or php(I am assuming you are familiar with JS and php).
3. High database IO - I don't know what scale you will be working upon but the only major thing you server will be doing is DB IO, hence you should choose some non-blocking technology and among them most famous is NODE.JS.
Node.js is something which is fulfilling every requirement.
If I were you, I would have choose express.js (express init and you are ready to go), Mysql (If you are not familiar with any NoSql as mysql seems to be fulfilling every requirement). And android app could be anything like cordova as app is doing nothing but HTTP request and some presentation of data.
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 9 years ago.
Improve this question
How can I publish an API with Java? In languages like C or C++ it is really quite easy because you can simply divide headers from code, but in Java this is a complete different story. So I know that there is no real way in Java you can obfuscate your code, even if you "obsfuscate" it, because it can be easily decompiled and analyzed. But if I don't simply can distribute headers to someone, what is the preferred way to publish a API in Java? I don't have special needs because I am in the beginning of the designing process so I am really dynamic and I would like to know all alternatives I have.
A clean way is to define your API purely in Java interfaces, include those into a separate API module and make implementation module depend on the API module. This does not provide the same functionality as separating C++ header files, but it is a good idea to program to interfaces anyway completely separating those from a particular implementation.
You don't need to publish your API as header files. Everything the developer needs is already in the JAR. If you want to publish documentation publish the java docs of the code.
You can obfuscate your code using a professional java obfuscator. Then it is not easily decompiled and readable. You can then publish your jars and javadocs like others have mentioned.
You could split your library into multiple jars and provide one with the classes and interfaces that form the api and another one that contains the implementations of those interfaces.
However, note that the hastle might not be worth it. Why exactly would you try and obfuscate code the users of that api would need anyways? What I mean is, that whoever would use your api would also need the implementations of the interfaces to run the application, so they'd still be able to decompile your code.
Generating an api-only jar would help with separating api and implementation though (which means you could replace the implementation or prevent accidential direct access to the implementation).
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 9 years ago.
Improve this question
I am trying study web development using Java but its seems very intimidating. all the tutorials are showing very complex methods, even the sample applications that came with NetBeans. I have some experience working with PHP but none with java.
Is there any simple way to use java on the server to just accept post requests and save to database and then display data from database without using things like javaServer faces?
Is it necessary to use frameworks like spring?
Pls forgive if i am asking stupid questions. i cant seem to find where to start learning from and tutorials seem too confusing.
Links to any good article will be very helpful
Thanks
For this purpose you should be familiar with the Servlet API, and preferably also with MVC frameworks and so on.
For the whole world to be a bit more straightforward for you and to steer away from the average-PHP-community-drawbacks (e.g. nobody tells you how to code well), I'd recommend to read THIS book.
But first of all, start HERE and then move on to THIS SITE.
The other way around (talking about DB access, not the web service here) is using raw SQL via JDBC which I won't recommend unless you have a good reason for it and you're already familiar with using a DB the right way (mysql and mysqli libs of PHP won't necessarily drive you the right path; PDO most probably will however).
Of course you don't necessarily need to use frameworks, but you're (actually in any language) way better off using them. Yes, probably the closest thing to the "nobrainers-php-methodology" (mindless coding; wiring UI, DB access and business logic together in a single file; etc.) is using the Servlet API, and then through a java.sql.Connection send your GET/POST data directly to the DB via JDBC. But doing so is slightly worse than cruelly murdering cute little squirrels/bunnies/kitties/insert_your_favourite_cute_creature_here
You'll also need a servlet container, most common of which is Apache Tomcat.
To learn Web Developing with Java Play Framework 1 is very nice:
Step by Step guide for a cool blog: http://www.playframework.com/documentation/1.2.7/guide1
Documentation: http://www.playframework.com/documentation/1.2.7/home
CRUD module documentation: http://www.playframework.com/documentation/1.2.7/crud
You get compile feedback directly in the browser.
Run your tests in the browser.
No redeployment to containers necessary/hot deployment.
No servlets.
Play 2 is already around, but going through Play 1 is much simpler if you are new a the Java world.
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 9 years ago.
Improve this question
I am currently in the process of analyzing the work of developing REST APIS for an Iphone Application using Java:
Firstly, Has anyone worked on development of REST APIs for iPad app or any other kind what is the kind of duration that requires to do it...and are there frequent changes in the REST APIs so that the project is a long one and my job is secure...or in general once you make APIS in 4-5 months maximum then that is THE END?
Are they something that a guy like me with no such experience in development of REST APIs can take up, are they in general something that only a guy with relevant experience can do?
If there are any good material on the internet about making them or anyway for me to get started with and go ahead with this:
I have just received the information that we need to develop 6-7 APIs for a start,,,any experienced guys about how much time it can take here is a sample workflow:
We have to click on Google maps..and based on longitude and lattitude we have to find a list of wholesale dealers related to our domain in that point and have to fetch them in JSON/XML Object...
Once the APIs are there, they are there and shouldn't change too often because it could break the app. So better put a lot of thought in the API design before you release it. How long it takes depends completely on the project. I can develop a REST API in a day, it could also take months, depending on the complexity.
It will take longer if you are inexperienced because you will need to do a lot of reading, especially when it comes to the architecture of the APIs. Again, impossible to say because we don't know your current skill-set. But in general: sure, if you are willing to learn you can do it, I don't see anything that would prevent you.
Lots of.. for a good framework have a look at Jersey. I also once found a good read about REST APIs in general: Link
As a conclusion, it's not necessarily only about developing the APIs, but also about the data you are trying to provide. Does that data already exist? Can you query it easily? How much logic do you still need in order to provide useful APIs? Those are the questions you should ask yourself as well.