I feel like missing something obvious or at least I feel on verge of "reveleation", but still can't get over it :)
I have a client selling transports from city A to city Z. The transport order is stored in MariadDB.
I want to help him utilize his trucks so when another client asks for transport anywhere within A to B, say C to X, I need to know :)
I started with Google maps API, but getting "cities" from the result is vague, quite complicated and expensive.
Considering client can work with "major" cities only, we set to create a graph of all major cities within the country.
Possible solution:
Thinking of using Djikstra's algo to determine a path within the graph, storing all the nodes of one transport order in DB and then querying any new orders against the DB to see if start+finish place falls within any other previous transport order...
If you can think of something quicker or simple, hit me with a link and a smile :)
Final toughts:
We're working with a website on nginx/php/mariadb, no substantial frameworks.
Our solutions would probably solve the problem on regional basis, but I am looking for a global solution, think worldwide transports... I searched stackoverflow questions, but I am not seeing an answer to this problem.
I am open to most ridiculous ideas, a friend of mine started talking about xpath in xml tree or regex... :)
thanks,
Alexander
Instead of assigning it, how about having a marketplace and having drivers grab jobs?
They know where they are going and where they are at any given time.
They also know if they are full or will have room at that part of their route.
So showing origin, destination, size, and weight for open orders would be good enough, I would think.
Related
I am reading a book and searching on the internet about this API path hirearchy and have not found anything solid yet, what I really want to know is where to put the id to retrieve/update/delete hirearchical API methods.
For instance I know I can do:
authority/resource/[id]/catalog/category1/category2
also:
authority/resource/catalog/category1/category2/[id]
in this previous example the problem comes when the next path from category2 (id) can be a numeric field to lets say update a value.
I do not really know if there is a standard about this way of building an state transfer API.
I can actually build my own and I was wondering if there are any standards or some aproach.
The "standard" allows lot's of interpretations on how you can design your hierarchy. There is not really THE way to do it.
However I think that this presentation:
https://blog.apigee.com/detail/restful_api_design
Is a good read on the topic. It outlines some design choices and also shows how some popular APIs (such as the ones offered by Google or Twitter) choose to design their URLs.
I'm just about to finish a marathon 9 month project-- a web app with over 70k lines of code. Problem is I hardly used comments, never used javadoc, and never kept any good documentation of any kind. (oh the guilt!! :) )
I now need to focus on the non-technical aspects of my business and pass this giant off to a programming team for maintenance and new features. So what can I do...what are the most useful comments/documentation to write? What's the best strategy for retroactive documentation? (Are there books on the subject?)
PS. Thanks for your months and months of help Stack Overflow. I barely knew HTML a year ago. You got me through it all!
70K lines isn't all that large. It might be larger than projects you typically work on, but at least it's not so large that one person can't understand most of it. That's probably what got you into trouble in the first place. It wouldn't kill you to go through each file and write a few sentences about what the class does.
70K lines is way too large to foist upon someone, or some team, without some sort of explanation of what it does and why. Take pity on your poor underlings (and reduce the man-hours that they'll waste scratching their poor heads) by at least writing a road map that explains in detail what the project does, how it's organized, which parts are important for performance or to meet requirements, which parts need work. If you had any written requirements for the project, those should be included.
I'd imagine that before you make your team work on this undocumented pile of code you plan to at least sit down wit the team members for a day and give them an orientation. Write down everything you'd want to tell them during that orientation. Give the team that document and some time to read it before you really do meet with them. Now you can use that day with them to refine the document by answering their questions. Ensure that the answers make it into the next revision of the document. Let your team's first task be to fix the problem you created. That'll help them get ready for the time when they do start implementing new features.
Be available to answer questions from the team for the forseeable future. Create some sort of system for organizing and preserving the information you provide. A wiki seems obvious, but you also want to make sure that new questions get noticed and answered quickly. A defect tracking system could work well. So could some sort of Q&A format like SO.
Change your attitude toward documentation. Learn from your mistake, change your ways, and encourage/insist on people spending time to document what they do. Try to make documentation as automatic as possible by connecting your defect tracking system and your version control system. Give your people the resources they need to produce useful documentation. Put someone in charge of documentation.
I tend to do just as you do, retroactively comment, if I comment at all. However, when I do, I try to document mainly my custom functions & classes, and important parts of my code. I note things such as:
Required Parameters
Return values
Explanation of the function
The best thing to do when commenting is think about what'd happen if you suddenly disappeared and couldn't explain your code. What would the developer who took over need to know and understand. Obviously, you shouldn't have made your code too abstract either (aka, only using variable names such as $x, $y, $z unless appropriate).
I am trying to create a website that will allow me to list all of the different types of beers I have tried including name, type, location, and brief tasting notes. I have a basic login created and believe that I will have to store the information about the beer in a database as well (with a cell for each of the elements). I was wondering a) if this is how people would suggest going about doing this and b) if anyone knows of good tutorials on how to set this up. I plan on using mySQL and PHP for the database and jQuery for the visual side of things. I am relatively new at this, so I am having trouble figuring out what exactly to Google to find what I am looking for.
I plan on going about it similar to a to-do list (only each element would have multiple attributes — name, type, etc.). Any help/suggestions/direction would be awesome! Thanks!
First off you need to decide on the features you want to implement, and then work out which to do first.
For example,
you need a database, which has a table for your beer info. (but do you need another one for people to have a user account too?)
you need to create a set of functions that you can access from the web site.
list beers
add beer
etc.
How do you want the front end to work?
How do you want the front end to look?
Once you know exactly what you want to do, it's much easier to break down the tasks into jobs you need the application to do.
I'd also suggest you look at Ruby on Rails (especially + the Hobo addon) to get you up and running faster (instead of PHP) - if you are set on PHP, have a look at CakePHP or another similar framework, so that you don't end up re-inventing the wheel.
Update:
Once you get started, further more detailed problems will be faced, many you can get a quick answer from google or the documentation for the language / database etc. If something is extra tricky, post another question on StackOverflow.
As it is your question is too general for a more specific answer, but if you need any additional info, just yell.
This question already has answers here:
Closed 12 years ago.
Possible Duplicate:
Where can I learn web programming from start to mastery?
I want to be able to make websites like facebook, youtube and google (and even stack overflow!), can someone suggest a step by step guide (as best as you can, if even for part of the way) and not just "Do tutorials and make websites".
I can't go to a we design company and tell them "I'll learn while making sites", or make a website for a client and it ends up being full of holes and security issues.
I'm interested in PHP as opposed to other types, but i'm open minded.
Your help is very appreciated.
Someone here offering a "step by step guide" is essentially the same as offering a tutorial, but with way more work involved.
The reason everyone on here says "here's a starting guide, go try it" is that that's how most of us learned, especially php.
So, this is exactly the answer you asked to not receive, but the absolute best method for learning is to have a goal in mind, and then build it.
Can you comment on this answer with a small project in mind? I'd be more than happy (or maybe other people too) to help get you started. But, I cannot tell you how to rewrite StackOverflow. I doubt the answer would fit in this text box.
Come back with "I want to rewrite Digg" or "I want to share recipes with friends" or something like that, and we can help you.
Edits based on comments below.
If you want to make a site like Craigslist, let's focus on one area for now.
Plan it out. What does your final product look like? Remember, you don't want replication of data, so think about what groupings of data you'll need. Things like categories, users, and posts, if we're keeping it simple.
You'll need to create a CRUD (Create, Read, Update, Delete) for each data group. This is a place to create categories, users, posts, view them, edit them as needed, and remove them.
You'll also want to connect these things together. So, for example, in a table of posts, you'll want a field called category_id or something, with the row id of said category. Then you can easily link posts to categories, view all posts in a category, etc.
What is your understanding of connecting to a database, retrieving results, etc? If this is completely over your head, I would definitely advise getting a book like the other answer suggests.
I think one of the best tools for learning PHP is the actual documentation. It is probably the best documentation for any language out there.
You can also go for books.
Say I have a collection of 100,000 articles across 10 different topics. I don't know which articles actually belong to which topic but I have the entire news article (can analyze them for keywords). I would like to group these articles according to their topics. Any idea how I would do that? Any engine (sphinx, lucene) is ok.
In term of machine learning/data mining, we called these kind of problems as the classification problem. The easiest approach is to use past data for future prediction, i.e. statistical oriented:
http://en.wikipedia.org/wiki/Statistical_classification, in which you can start by using the Naive Bayes classifier (commonly used in spam detection)
I would suggest you to read this book (Although written for Python): Programming Collective Intelligence (http://www.amazon.com/Programming-Collective-Intelligence-Building-Applications/dp/0596529325), they have a good example.
Well an apache project providing maschine learning libraries is Mahout. Its features include the possibility of:
[...] Clustering takes e.g. text documents and groups them into groups of topically related documents. Classification learns from exisiting categorized documents what documents of a specific category look like and is able to assign unlabelled documents to the (hopefully) correct category. [...]
You can find Mahout under http://mahout.apache.org/
Although I have never used Mahout, just considered it ;-), it always seemd to require a decent amount of theoretical knowledge. So if you plan to spend some time on the issue, Mahout would probably be a good starting point, especially since its well documented. But don't expect it to be easy ;-)
Dirt simple way to create a classifier:
Hand read and bucket N example documents from the 100K into each one of your 10 topics. Generally, the more example documents the better.
Create a Lucene/Sphinx index with 10 documents corresponding to each topic. Each document will contain all of the example documents for that topic concatenated together.
To classify a document, submit that document as a query by making every word an OR term. You'll almost always get all 10 results back. Lucene/Sphinx will assign a score to each result, which you can interpret as the document's "similarity" to each topic.
Might not be super-accurate, but it's easy if you don't want to go through the trouble of training a real Naive Bayes classifier. If you want to go that route you can Google for WEKA or MALLET, two good machine learning libraries.
Excerpt from Chapter 7 of "Algorithms of the Intelligent Web" (Manning 2009):
"In other words, we’ll discuss the adoption of our algorithms in the context of a hypothetical
web application. In particular, our example refers to a news portal, which is inspired by the Google News website."
So, the content of Chapter 7 from that book should provide you with code for, and an understanding of, the problem that you are trying to solve.
you could use sphinix to search for all the articles for all the 10 different topics and then set a threshold as to the number of matches that what make an article linked to a particular topic, and so on
I recommend the book "Algorithms of the Intelligent Web" by Haralambos Marmanis and Dmitry Babenko. There's a chapter on how to do this.
I don't it is possible to completely automate this, but you could do most of it. The problem is where would the topics come from?
Extract a list of the most non-common words and phrases from each article and use those as tags.
Then I would make a list of Topics and assign words and phrases which would fall within that topic and then match that to the tags. The problem is that you might get more than one topic per article.
Perhaps the best way would be to use some form of Bayesian classifiers to determine which topic best describes the article. It will require that you train the system initially.
This sort of technique is used on determining if an email is SPAM or not.
This article might be of some help