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'm designing a chat aplication where the data will be stored in an mysql database and will be manipulated by php scripts.
I want to have the possibility of developing severall diferent clients. What are the best options to expose the funcionality of the php scripts to clients?
Thanks
(As I said in a comment above, this isn't an MVC pattern at all.)
Typically, what you're trying to achieve can be done by developing a web-service to expose certain features of your application running on your server (and storing data in your database). You would need to define message formats to be exchanged between your client and your service. This is typically based on JSON or XML syntax.
Just a few more points:
-Data- To store the data, that is, the messages and user info, i selected mysql because that's what's available on apache.
MySQL isn't available on Apache (Httpd). Apache and MySQL have little to do with one another, besides the fact there are "LAMP" stacks that bundle them together. In principle, nothing prevents you from using another RDBMS (e.g. PostgreSQL, MS SQL, ...) or even NoSQL databases.
-Controller- To access and manipulate data i've chosen php because that's what's available on apache.
Again, PHP is a popular choice to run on Apache Httpd, but PHP is far from the only choice (you can implement services in Python or Perl, for example).
-View(Client)- It's possible to develop diferent clients, as long as they can interact with the php scripts that have access to the
database. For now, i'm using Java to build the client. It has the
advantage of being used either as an applet or as a standalone
aplication that can be downloaded.
It's 2013, Java applets are a technology of the past. (Standalone Java applications or server-side Java are different.)
I'll have cron jobs to select the last messages from each of the chat
rooms. Theses messages will be writen on to a file. Each chatroom will
have its file. To read the messages, the client has to ask for the
corresponding file and present its content to the user. To send
messages to the chat rooms, the client has to call the php script
passing informations like the destination chatroom, user id and so
on.. Insertions will be heavy on the database but reads will be a bit
lighter.
This is a clear case of premature optimisation, or inadequate optimisation (cron jobs run at best every minute, not ideal for a chat room). A well designed database (e.g. with appropriate indexes) might not have problems handling chat room traffic. You might want to read a bit more about web services and databases before trying to dive into this sort of details.
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 9 years ago.
Improve this question
I'm working on a project that involves several applications on several computers. The main application is a C++ socket server running on a CentOS server, and the client application is a Java program running on client PCs.
These will communicate back and forth using sockets. I have defined a set of commands and arguments that they will need to implement in order to support everything.
I've thought of several options, but I can't seem to find the perfect one..
Should the C++ and Java program write their own classes/parsers for validate the messages?
Should I create an XML file (served over HTTP) that defines all of the communication messages? (That the server/client would parse and create actions for)
Or use some kind of third party library (Google Protocol Buffers?)
The point is that when the Socket server sends a message X, then the client must know what to do with it. Same applies the other direction.
What would be the best way to implement this? Having the XML file would be nice, as the client/server may parse it and create methods/actions based on the data. But a more clearer approach would be to create classes that would do the parsing.
I always do this the binary way. First you must decide what underlying transport protocol to use, it could be UDP, TCP, TCS, SSL. I would start with the TCP, since it's very stable and easy to use.
A simple way to handle packages is by in each package begin with a number that specifies which package this is. The based on this number you send the package to a corresponding class that handles the data. This can be done easily in both C++ and Java. I think it's easier in C++ since there you can base don't he first number read in a entire struct, but in Java you generally have to read it primitive by primitive.
Remember that the standard over the internet is to use big-endian values, but the normal on the most machines today (Intel, AMD, ARM...) uses little-endian values. So in C++ you will have to flip all primitives before sending them. And you have to flip the received values as well. I don't know if Java does this for you...
ICE by ZeroC is a cross platform and cross language library for TCP/IP communication between C++ and Java. I've used ICE to communicate between Linux/AIX/Solaris for C++/Java programs without problems. ICE uses a binary transfer protocol that does the big-endian/little-endian conversion for you. The downside of ICE is that you need to define the messages and calls using its custom language.
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 5 years ago.
Improve this question
I'm starting a new web based enterprise application, and I'm thinking of using Wavemaker.
I'm a fairly experienced java-ee developer, but it seems to me that even in this case, WaveMaker still makes sense to develop the application fast and focus on the business logic.
My questions are :
1- Are their any drawbacks to this platform
2- Can I do all the normal things from the server side easily (like sending mail,building birt reports, adding jobs)
3- Can I freely manipulate javascript (for example for specific animations, using plugins....)
4- Can I integrate realtime processes, like websockets ?
Thank you
I've used Wavemaker in an Enterprise application with success. We used quite advanced features such as heavy use of backend logic based on JavaServices, an run-time SQL database selector made inhouse, JS plugins for the frontend, obfuscation etc
We later recruited a devteam to take support of this application and, although the community is small, the team learn quickly and was able to maintain the code base.
As I see it, Wavemaker is a excellent tool if you like to:
deploy a web-based CMS for your midsized SQL database
deploy a smaller web control page for your java back end system
To answer you questions:
1) Small community: Although the community is friendly and on their toes, it is too small to ensure the type of feeback you might be used to. You will have to spend quite some time banging your head to the wall when you try to go beyond the example applications.
2) Yes, you have all the freedom you would expect from a Java backend. Simply said; each REST api is assigned to a Java Method, its up to you to implement the logic. I have built wavemaker on SQL, mongoDB. With email interactions, data parsing, file upload/download etc You name it
3) Yes, you can add JS plugins and customize the scripts generated by Wavemaker. You might want to make sure that you don't edit the auto generated JS, since they will be overwritten. but as soon as you found the right entry point you are free to customize just the way you like it.
4) Yes, since you build you own back end in java you are free to open up any type of communication you like to have. And since you are able to customize the front end js you will be able to read this data. But as I said in question 1 - there will only be a small community helping you
So to sum it up:
I vote for Wavemaker, but make sure to only deploy it if you application will be similar to the templates/demo provided, if you build a unique system you might like to look into other solutions.
All choices have drawbacks. There is not a lot of WM expertise to be had. You'll need to deal with some issues in terms of the library at hand, dojo, spring etc instead.
you can,but it requires some java knowledge. You are operating in a spring MVC you can
you can, you are operating in a dojo client there
possible, probably. worth the effort, doubt it.
1- Drawbacks- It's enterprise focused platform, so will require own effort to learn it.
2- Yeah, you can do pretty much all normal things (at least from my experience, till now)
3- The tool has kind of open-source configuration so its easy to manipulate or customize your codes if needed
4- From my experience, WaveMaker has one of the best and most diverse integration options available.
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 planning to program a software (in java), which will be (hopefully) used very much. In the beginning I may run it on my own server, but if it becomes popular my server will most likly crash.
So my plan is to program it for a cloud service like Amazon EC2, Google App Engine, Lunacloud or others.
The application will not have a gui for now. It will concentrate on SOAP or JMS (or something like that) and should store a lot of data in a relational database (PostgreSQL would be nice).
Since I am new to the cloud services, I tried a little bit with GAE. The main use is easy, but as soon as I use JPA and ManyToMany-Relations GAE is shit. Also making a SOAP or JMS Server in GAE is not simple.
Since I lost my weekend with trying GAE, I thought it would be a good idea to ask the community.
Which cloud service will fit best for my requirements? What are the benefits and differences between these services? What else can you recommend?
This is question is too wide open to provide a good answer, but here is some tips that should help.
There is a difference between platform as a service (GAE, Jelastic, Heroku) and Infrastructure as a Service (EC2).
In the platform as a service category, you have more of an automated infrastructure, and often very little visibility of the underlying components. This can make things easier from a developer perspective, but it has its downsides. You are often locked into how a provider works and it may be difficult to switch. You may also have limitations as to what you can do with your application.
In the Infrastructure as a Service category, you get access to virtual machines that you can configure and automate yourself. You have more flexibility on this type of platform, but you are generally expected to handle more of the work yourself. EC2 does have its own version of platform as a service with elastic beanstalk.
i would recoomend also heroku because it does not have a traffic limit and you can run a basic instance for free. if you dont need nosql dbs and extra software it will be very cheap and the unlimited traffic is good for your webservices. Gae has is own filestructure so i can understand your problems with your db structure very good. heroku and ec2 does not restrict your plans but ec2 is generally expensive if you dont plan to scale up and down often. heroku gets also very expensive when you want to add extra software and scale up. i dont know if youre able to scale up as good as with ec2 if you want to use jelastic.
another but complex approach would be renting some normal root servers with unlimited traffic where one instance act as load balancer but you would have to do the configuration by yourseld
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I've been programming for a while now, and I am pretty familiar with Java and PHP and websites. What I'm confused about is how programmers use them together. I hear about how Facebook and Google use all sorts of languages like Python, C, Java, PHP all for one product, but I'm just confused on how that would be possible.
Also, another side question:
What work exactly do software engineers do when working for large online companies like Twitter and Facebook? Most of the code deals with database and information, and so what major level programming, besides what can be learned online with a few tutorials, needs to be done on the server side?
This is an incredibly broad question, but here's a shot at a vague answer. Often times large applications will have a number of components. For instance, you may have some sort of reporting engine, business logic, web interface, desktop interface, web service API, mobile interface, etc, etc, etc. Each of these could, in theory be written in a different language and communicate via a database or something like a web service.
To your second question. At large companies there is a great deal of work to be done to maintain stability, develop new features, fix bugs as they are discovered and work to increase efficiency etc. Facebook, for instance (and Google) employs a large number of software engineers to help them deal with the massive amounts of volume they receive on a daily basis.
Edit Here's a bit more clarification and a direct answer to your question.
Most of the code deals with database and information, and so what major level programming, besides what can be learned online with a few tutorials, needs to be done on the server side?
The truth is, for the most part, the high-level principals are the same. You could pretty easily build a Facebook clone after doing some basic PHP/MySQL tutorials on the web. Here's the difference: your clone would die before it reached a fraction of the users Facebook sees on a daily basis. It would be slow, unreliable and people would leave because their data would be consistently hacked through SQL injection and other malicious attacks. And that's not even talking about distributed computing. So, yes, from a high-level, that's all you need to know. The implementation and reality is much, much more complex.
As you might expect, larger "websites" are not built in the traditional sense that you have some PHP code, a few HTML templates and a database, since this kind of architecture has severe issues scaling to thousands of concurrent users.
What you can to to mitigate this is split the website out in several components:
Load balancers that distribute requests to several App servers
App servers which generate the UI and handle user actions
Middleware servers that handle business logic and distribute it among DB servers
DB servers that store data in some way
Every component of this system might be implemented in a different language and you might even have different app servers depending on request type (e.g. mobile devices).
This type of system is called Multitier Architectures. You can also find academic books on this topic.
Most complex products consist of numerous pieces. For example, StackExchange has code that runs in your browser that's written in JavaScript so it can run in your browser. But the code that builds the web pages doesn't run in a browser and so isn't written in JavaScript. And if complex database queries are needed, they're likely to be in SQL. And so in. Each piece of the big puzzle is implement in the language most appropriate for what that piece does and the environment in which it runs.
Thank about GMail. There's a in-browser piece that's written in JavaScript. There's also a web server, a database, a mail server, a bulk storage system, indexing, and many, many other pieces.
this is the actual answer you are looking for
you are confused because you dont see how using the C and C++ applications in websites but I want to tell you that, they are used for many things... like, when you upload a image in facebook containing pornographic content, then php wont validate that image, what they will do is that execute a program by passing the address of that image by parameters and that application will validate the image... and some data should be stored for future use, so that application uses the common database that the site is using, if we upload a image in googleplus, then it will load tag sugestion to some part where people's faces are seen, it is done by that app, it will save the image data to the common database which google is using and php takes that information from there, this is the technique of developing much more functional websites...
like, i have made a program to shutdown my home computer while working on localhost:
<?php
$command="shutdown -s -f -t 5";
shell_exec($command);
?>
this script once run in apache will shut the server down similarly you can pass the parameters into some apps like if you want to create email account in command line for your own server which dont have Cpanel installed...
and the answer of second part of your question:
actually software engineers are hired so that they will develop some apps that can be run in a server for increasing the functionality of the website... like if there would be only webscripting language for websites, then google couldnot recognise the face neither facebook, and artificial intillegence would not be possible for websites..
this post may clear your confusion...
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 5 years ago.
Improve this question
I have not had much experience with Webservices or API's.
We have a website built on Oracle->Sun App Server->Java->Struts2 framework. We have a requirement to provide an API for our system. This API will be used by other systems outside of our system. API is just for a simple SP that we have on our database. The other system does not want to connect to our DB to gain access to the SP but instead and an API as a 'webservice'
Can the community please shed some light on how to go about this? Will the API be put on our webserver? is that how the other system will connect to it? And how to go about creating a public API?
Some things you'll need to think about are:
SOAP vs REST (Why would one use REST instead of SOAP based services?)
How will you handle authentication?
Does it need to scale?
You might want to take a look at https://jersey.dev.java.net/.
It would also be helpful to look at how another company does it, check http://www.flickr.com/services/api/ for some ideas.
If you are using the Sun App Server, it should be fairly trivial to make an EJB exposed as a web service with the #WebService tag, and then have that EJB call the Stored Proceedure and return the data. The app server gives you tools to publish a WSDL which is what they will use to know how to call you API.
That being said, what sounds easy at 50,000 feet is a real pain to deal with all the details. First, what about security? Second, are WebServices really required, or is there a better communication mechanism that is more obvious, such as (at a minimum) REST, if not some simple servlet communication. And the hardest part: In exactly what format will you return this result set?
Anyway, you could be dealing with a bit of a political football here ("what, you don't know how to do web services, everyone knows that, etc.") so it can be a bit hard to probe the requirements. The good news is that publishing a web service is pretty trivial in the latest Java EE (much easier than consuming one). The bad news is that the details will be a killer. I have seen experienced web service developers spend hours on namespace issues, for example.
Soap or Rest or .. is one side of the medal and depends on what the clients want.
The other (more) important thing is the api design itself. Shall it be stateless or stateful. Are clients co-located in the same VM (Appserver) or remote in the same LAN or even in a Wan.
As soon as the communication goes over the wire, it gets slow due to serialization. So you want API methods to obtain bigger (but not too big) chunks of data at a time.
Or in other words, your question can not really be answered without knowing a lot more about what you want and need to do.