2,515 karma · joined Mar 4, 2010 (16y ago) · 549 submissions
meet.hn/city/43.1009031,-75.2326641/City-of-Utica
---
comment 3y ago · link · parent
class ApplicationForm
extend Portrayal
include ActiveModel::Model
class << self
def from_params(params)
new(**filter_params(params))
end
def filter_params(params)
params
.require(model_name.param_key)
.permit(*portrayal.keywords)
.to_hash
.transform_keys(&:to_sym)
end
end
end
class MyForm < ApplicationForm
keyword :first_name
keyword :last_name
validates :first_name, :last_name, presence: true
end
Can use it in a controller action like form = MyForm.from_params(params)
if form.valid?…
# the usual
One of the good things about this approach is that you can also use this object in form_for/form_with in your views.comment 3y ago · link · parent
comment 3y ago · link · parent
comment 3y ago · link · parent
457.
Rails – narrative vs. model centric approach(max.engineer ↗)
1 points · by hakunin · 4y ago · discuss
comment 4y ago · link · parent
459.
Good Engineering is not Premature Optimization(max.engineer ↗)
2 points · by hakunin · 4y ago · 1 comment
461.
It's Not Premature Optimization(max.engineer ↗)
1 points · by hakunin · 4y ago · discuss
462.
It's Not Premature Optimization(max.engineer ↗)
2 points · by hakunin · 4y ago · discuss
comment 4y ago · link · parent
comment 4y ago · link · parent
465.
I Love Ruby: 65LOC for Neat Atlassian Document Format(github.com ↗)
1 points · by hakunin · 4y ago · discuss
comment 4y ago · link · parent
Also very convenient for casual writing/editing from any device where an app can sync via Dropbox. Can fix a typo on an iPhone via something like 1Writer while on the go.
467.
Sshfs Is Orphaned(github.com ↗)
191 points · by hakunin · 4y ago · 98 comments
468.
Ask HN: How do you plan back end work?
4 points · by hakunin · 4y ago · discuss
comment 4y ago · link · parent
comment 4y ago · link · parent
My preferred email validation is a combination of string contains '@', actually sending a verification email and/or making an MX lookup.
comment 4y ago · link · parent
comment 4y ago · link · parent
I think there is a small distinction in the act of engineering vs. developing, but we all cross that line without noticing. Software engineering is the process of finding the most efficient solution within your constraints by leaning on algorithm/datastruct fundamentals. For example, you don't look at a tool's marketing page, you look at what it's built upon, how it operates, and based on these fundamentals you understand how performance, reliability, and cost will scale. If the fundamentals are too complex, you might have to do some measuring. If you evaluate or build new tools on this basis, you engage in some software engineering. I don't think this has to be some sort of superior gate-kept thing. It's just a kind of work.
We could make a stretch and claim that there's also "fundamental analysis of maintainability", but I firmly believe[1] that maintainability is subjective. We don't call writers "story engineers", and I wouldn't call any immeasurable and subjective work "engineering".
Edit with additional thought: I think there is a perception downside to both: developer and engineer. The "developer" downside is that you're more likely to be perceived as someone who doesn't care about fundamental analysis, and you focus on getting things to work only in the conditions you're familiar with (i.e. on my machine). The "engineer" downside is that you're more likely to be perceived as someone so fixated on the measurable, that you completely ignore the taste and maintainability aspect (falling into the McNamara fallacy). If you can't measure it, it's not worthy of your time.
There are just perceptions, not reality. Naming is hard.
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
comment 5y ago · link · parent
> Firstly you cannot please everyone
> And secondly, programs are not structured for pedagogy
My theory is that you only need to please a couple of maintainers that work with you, not everyone. That's why I proposed a test with 2 colleagues at the end. It could potentially be spiced up with 2 colleagues of different levels. I believe this can act as one of those 20% effort to get 80% there, but definitely don't claim to have proof of this.
480.
Writing maintainable code is a communication skill(max.engineer ↗)
297 points · by hakunin · 5y ago · 93 comments