Better HN
topnewbestaskshowjobs
Log inSign up

programminggeek

5,207 karma · joined May 21, 2010 (16y ago) · 1,593 submissions

I am a builder. I build lots of things.
Submissions

1201.

Show HN: The Obvious Architecture(obvious.retromocha.com ↗)

19 points · by programminggeek · 13y ago · 13 comments

comment 13y ago · link · parent

You know what the right play on Zynga was? Cashing out and putting the money elsewhere. Instead, Zynga is the classic case of thinking that growth is basically infinite and there is unlimited demand. There are a limited number of gamers willing to buy virtual goods on Facebook games, and there is nothing special that Zynga does on mobile that other companies don't do as well or better.

Take the money and run. Now it might be too late.

comment 13y ago · link · parent

I would TDD in either case simply because if you end up maintaining it at all, you're going to wish you had tests. Also, I wrote an architecture that makes starting from day one using TDD much easier. It's called Obvious: http://obvious.retromocha.com

Once you understand the concepts, you can whip up a simple crud app in a couple hours. Example app here: https://github.com/RetroMocha/obvious_status

comment 13y ago · link · parent

If they are open source, how are they elusive? Something freely available and posted to HN isn't elusive at all.

At least a name like Font Awesome is somewhat self-descriptive or obvious.

Nice icon set nonetheless.

comment 13y ago · link · parent

I agree.

comment 13y ago · link · parent

Growth Hacking is apparently a secret word used to Hack Hacker News. Are there other secret words we have not yet discovered?

comment 13y ago · link · parent

I agree that avoiding schema doesn't solve the problem. My point is that your schema exists in your code one way or another (explicitly or implicitly), and even without a database schema, you still need to either handle the schema differences in your code, or you need to migrate your data into the new schema in some way or another.

The best use of schema-less data storage I've heard of is Craigslist of MongoDB for their archives. Apparently migrations on their MySQL servers was taking way too long, and switching that system to Mongo made a lot of sense and apparently has worked out pretty well.

In the end it's about understanding the use of the right tool for the right job.

comment 13y ago · link · parent

I don't think that schema or schemaless should change your app structure. Your entities/models should contain your data structures. If you structure your application right, schema doesn't matter. In fact, your persistence mechanism shouldn't either. Mongo, Mysql, Redis, they're just different ways to store and retrieve your data.

The biggest reason to avoid schemas is to avoid schema migrations. On big enough datasets, they take a long time. That is not every app's problem, so it depends on your app. Also, not having a schema doesn't mean you completely avoid data migrations as a result of changing your schema in all cases.

comment 13y ago · link · parent

A paywall can work for the same reason iTunes works. Most people aren't thieves and are willing to pay for quality things. In short, make something good and charge for it. That business model has worked for a long time and will continue to work for a long time.

The biggest "problem" is that it will be harder to build as many giant media companies around general news distribution. On the other hand, a bunch of smaller players will have a chance to flourish. A lot like modern digital music.

comment 13y ago · link · parent

I can't wait to get my dev console. Not sure what game I'm going to build, but I'm super jazzed either way.

comment 13y ago · link · parent

Rails doesn't have to be a one size fits all framework if you use it as a web delivery mechanism. That is the point of the Obvious Architecture http://obvious.retromocha.com/ You can see an example "twitter" app here: https://github.com/RetroMocha/obvious_status

In the case of my example you could swap out the /delivery/web/app.rb or delivery/api/app.rb out for rails no problem. You wouldn't need to change any of the code in /app or /external to do so whatsoever.

Just because DHH thinks you should write your code one way and you don't agree doesn't mean you have to throw rails away entirely to have a different or better structure. Rails might be opinionated, but that's just like their opinion man.

comment 13y ago · link · parent

I work at Firespring (http://www.firespring.com) in Lincoln, NE. It's an awesome place to work. The project I work on is LAMP for the site with some ruby api backend mixed in.

My side projects are where I have the most freedom and I just recently built and open sourced Obvious - http://obvious.retromocha.com. It makes it easy to build apps with good structure, good testing, and with pluggable front and back ends. So, if I want to switch out Mongo for MySQL or Postgres, it's basically painless.

comment 13y ago · link · parent

It's cool to hate MongoDB, it used to be really cool to like MongoDB. Same thing happend with MySQL probably 10 years ago. I have built some apps with Mongo and it's fine as long as you don't expect it to be a SQL database. A lot of times I wish it had features x,y,z from sql land, and other times I wish MySQL was schemaless.

Nowadays, I have begun to defer my database choice until I absolutely have to put an app into production if possible. That way I can write an app and have it working without worrying too much about queries, caching, and so on until I need to actually put it out on a real server.

MySQL, Mongo, HBase, Cassandra, Postgres, Riak, Redis, Memcache, Couchbase, Filesystem? It doesn't matter.

They're all going to break at different times for different reasons depending on how you use them and what scale you are at. Everything breaks at scale eventually.

Build something awesome enough that it breaks under the user load. That's a good problem to have.

comment 13y ago · link · parent

Start by figuring out how to make it better. As in, automate the boring parts and fix the parts that suck. Also, start building something cool. Like, seriously, build something cool. Even if it's just for you.

I've been geeking out about software architecture and engineering lately to make TDD not suck, so I built Obvious to scratch my own itch. It's the most fun I've had building software in years. I don't know if anyone else is going to care, but I've enjoyed it immensely. http://obvious.retromocha.com/ if you're curious.

comment 13y ago · link · parent

ActiveRecord is certainly a huge part of the problem and it is the first thing to decouple from your models. However there is a wonderful benefit to making since action objects - you can cleanly do dependency injection without side effects on the rest of your service. That makes testing them much cleaner and more obvious. The other really cool thing you could do is wire actions together with different sources. That could make things like data migrations between different data sources trivial or adding caching to smaller slices of your system easy.

comment 13y ago · link · parent

Too much abstraction or indirection will certainly lead you down that path, but that is not really what I would advocate at all. With Obvious the goal is to make it feel obvious what the system is doing. No big complicated inheritance systems. Instead it uses a bit of indirection via dependency injection and reflection to make the data plugs swappable. Nothing too crazy or complicated.

comment 13y ago · link · parent

I'm coding those bits today. What is up so far is 3 hours of coding last night.

comment 13y ago · link · parent

I agree. I based the Obvious Architecture around Uncle Bob's blog posts Clean Architecture and Screaming Architecture. It's taken months of testing, building and thought, but I think it's come out pretty nice on the other side. Both the delivery mechanism and the external persistence mechanisms are separate and pluggable from the app code itself.

You can go in the app/ directory of a project and read the file names of your actions and entities and know right away what the system does. Testing is fast because it never hits a database. Test doubles and mocking are easy to build and don't require a 3rd party lib. Data traveling between the app and the external systems is validated via contracts. It ends up being the most enjoyable TDD experience I've ever had.

For example, last night I put together an example "twitter" status update app in obvious. I got all the entities, actions, and contracts written TDD in about 3 hours. Today I'll be adding a delivery mechanism and probably filesystem and mysql plugs. Would be easy to write an api or console app and plugs for mongo, postgres, or whatever. Code is here: http://github.com/RetroMocha/obvious_status

comment 13y ago · link · parent

It doesn't hurt performance in any noticeable way. Your database plugs are passed into the actions. The plugs are designed to do only what you want them to do, so you can tune them to your hearts content. In fact, I would argue it is far easier to tune a query in Obvious than it is in a traditional ORM which hides the query from you.

This is done via simple dependency injection, which is pretty standard in many other languages outside of ruby.

comment 13y ago · link · parent

I think part of the problem is that if you start with the naive way, you get some bad habits and start looking at your code through the lens of ActiveRecord - fat models, persistence, concerns, etc.

If your models were just plain ruby objects that validate your data for you, your code is able to do more interesting things - like multiple persistence mechanisms, multiple delivery mechanisms. Oh and they can be incredibly fast to test from day one.

If you use a tool like Obvious (which I wrote), you can TDD from day one and still build things fast, while maintaining a good structure.

comment 13y ago · link · parent

I've been working on the Obvious Architecture, which seeks to decouple your app from both the database and your web framework. Treating Rails or Sinatra or whatever as just a delivery mechanism frees you from a lot of of the potentially bad design decisions that your web framework made about how you should structure your app, the worst offender of this is how rails implies the use of ActiveRecord. You should use Rails for what it's good at - web stuff (routing, asset management, view engine integration).

I've got an example Obvious twitter close/status update app in progress at https://github.com/RetroMocha/obvious_status

Obvious is still super new and I'm working on documentation and examples. You can read more about Obvious at http://obvious.retromocha.com

comment 13y ago · link · parent

I think a great way to deal with this is to have services/actions that return the appropriate hashes. Pass the hashes into your views and let them do what they're going to do with them. You won't have biz logic creeping into a view that way because views are dealing with dumb hashes, not real entity objects.

comment 13y ago · link · parent

Hey, I'm not the OP, but I have some thoughts based on my experience creating the Obvious Architecture.

1) Hiding persistance from the programmer by tying it to your models is a bad idea. It's where a lot of problems start. First, how do you test without hitting the database? How long do your tests take? Minutes? Hours? Or do you skip them?

I don't think your models should do persistance at all. They should model your data for you. Do validation against your business rules. That sort of thing.

Would you tie your models to the filesystem? If not, then why would you tie them to the database?

Pulling your persistance mechanism out of your models is the first step to writing fast, maintainable, highly testable code, even if you are still using rails.

2) Rails conventions want you to tie your DB to your objects, which is a bad idea. Rails does a lot of things well, like it gives you a nice structure for controllers, views, routing, asset management, so use it for those things. Rails is a delivery mechanism. Use it as one and leave data modeling and persistance to something else.

3) I think the name issue could be solved by treating it as "action" object. Think of actions as more like actors. They do things. They integrate models/entities and persistance mechanisms along with minor amounts of logic that don't fit inside of entities.

As an action object, you could all it CreateContact and it would be called create_contact.rb in the app/actions folder. Then, when you look in the app/actions folder, the file name communicates what it does - it creates a contact.

4) Actually, it helps a lot with testing. Creating a new class makes dependency injection super easy, making testing super easy and fast. Also, it can help with clarity and glance factor. Imagine you have an app/actions folder with files like create_contact.rb, remove_contact.rb, send_email.rb, get_contact.rb, compose_email.rb and so on. You look at that folder and you can see that it is probably an contact management and email app. Maybe an contact or newsletter management app?

That kind of glance factor you can't get with a bunch of higher level controller or service containers. It also avoids the problem of "what controller/module/service does this method belong to?"

5) I actually agree that the code that the OP did was not the best in that the persistence and email sending mechanisms aren't passed in to the action, so that you don't know what it is going to try and save and where. If the code explicitly passed in the persistence and email mechanisms it would be more apparent that an email is going to be sent as part of the CreateContact action. That being said, I would probably make those two separate actions for clarity's sake.

I've written some apps using the Obvious Architecture and it really does help solve a lot of the problems that default Rails MVC creates.

comment 13y ago · link · parent

It really depends on what the system needs and how you are reusing functionality. Creating a user on the front end of the site with a new user sign up makes sense to send an email, but if you have a back-end admin area, creating a new user there probably wouldn't be a good idea to send out an email in many cases.

In short, use your head. There is nothing wrong with breaking out this functionality into two actions.

comment 13y ago · link · parent

In the Obvious architecture, it would be something more like..

    class CreateContact
      def initialize contact_jack, email_jack
        @contact_jack = contact_jack
        @email_jack = email_jack
      end
    
      def do input
        # validate input
        
        contact = Contact.new
        contact.populate input

        contact_jack.save contact.to_hash

        email = ContactEmail.new
        email.populate contact.to_hash

        email_jack.send email.to_hash

        contact.to_hash
      end
    end
With that structure you can call CreateContact with:

    action = CreateContact.new
    result = action.do ContactJack.new, EmailJack.new
In that structure you can totally test the action and logic without hitting the db or the mail system at all. Your ContactJack and EmailJack can be easily swapped out for various pluggable data stores. Fileystem, MySQL, Mongo, Postgres, Cassandra, could be swapped out for the ContactJack. EmailJack could send through standard mail servers, SendGrid, Amazon AWS, Mandrill, etc.

Obvious is on github, you can read more at http://obvious.retromocha.com

comment 13y ago · link · parent

Ok, I've been working on an architecture pattern that is very similar to this idea and it's basically inspired by Uncle Bob's Clean Architecture and Screaming Architecture posts. I call it the Obvious Architecture.

What the OP writes about is a good first step and frankly, is very close to right, but why stop there? Why not ditch ActiveRecord models all together and totally decouple persistance from the "app"? Honestly, the coupling of your models and logic to a database is really where most of this trouble starts.

In the Obvious architecture the app is separate from the delivery mechanism (rails/sinatra/whatever) and also from the external persistance mechanisms like databases, queues, caching, and so on. You can mix and match both delivery mechanism and persistance methods. So, you could write a CLI app against the filesystem and then make a rails web app with a mysql persistance mechanism without changing your "app" at all.

The whole thing is built from day one to be TDD and in a recent app I wrote, it has some 78 rspec tests that run in 0.03 seconds.

I'm in the process of documenting and open sourcing the whole thing. There is a project generator gem available now called 'obvious' and you can read more at http://obvious.retromocha.com/

When I have better documentation and examples available, I plan on posting to HN, but all questions are welcome.

comment 13y ago · link · parent

I think programmers overstate the demand for servers vs. clients. By definition client machines could be 10 - 100,000 per server. So, yes, intel can sell a lot of powerful server chips, but the high volume client machines like desktops, laptops, phones, tablets, etc. are moving away from x86. That is bad for intel and AMD and x86 in general.

comment 13y ago · link · parent

The problem is 2-fold ARM is being supported by a lot of companies - Apple, Samsung, Microsoft, etc.... vs Intel by itself on x86 basically.

Second, ARM chips are too cheap. Intel's biz is built on $100+ chips. ARM chips are like $10. If intel's chip prices drop to say $25, they don't have nearly the money for R&D.

X86 won't die, but it can't grow and over time that's going to hamstring Intel.

Call it peak x86.

comment 13y ago · link · parent

I think that assumes some serious hand waving on the part of both your app and the api's. Assuming that just pointing at the root of another API is going to mean your app will magically behave properly using both API's is making a lot of assumptions either in your app about how the API's work. For example, say one API calls a delete call "delete", another calls it "remove", another calls it "obliterate", and at the same time one API takes an id on that method as input, another takes an email address, another takes a username. In that scenario your app might be written to remove something based off an id and when you switch API's the new one expects you to obliterate based on username. Hypermedia doesn't save you there.

I'm all for pluggable protocols and standards, but Hypermedia links in your API don't magically get you there. They might help, but no more than a standard spec with standard URL patterns would.

comment 13y ago · link · parent

I think I'm more shocked to see foxnews.com linked from HN.

Also, if you're planning on doing this yourself, start with the Minimum Viable Ark and see if other people and animals are willing to join you before going all in on the full ark yourself.

1
404142
54