<nona>
and i'm wondering why sometimes i see `thing.that_can_go_wrong rescue raise StandardError` and sometimes `thing.that_can_go_wrong rescue StandardError`? the latter seems kind of nonsensical.
BazzaBazaa has joined #ruby
momo- has joined #ruby
momo- has quit [Ping timeout: 260 seconds]
konsolebox has joined #ruby
<sarna>
to me sounds like the real problem with inline rescue is that it's a bare rescue?
<sarna>
it'll rescue *all* exceptions, including typos and such
<sarna>
so the regular caveats wrt bare rescue apply
finalblast has joined #ruby
<nona>
hmm yeah it is overly broad
<nona>
thanks for the shift of perspective
jetchisel has quit [Quit: Unfortunately time is always against us -- [Morpheus]]
jetchisel has joined #ruby
momo- has joined #ruby
TomyWork has joined #ruby
markong has joined #ruby
BazzaBazaa has quit [Remote host closed the connection]
valley has quit [Remote host closed the connection]
valley has joined #ruby
jhass has quit [Quit: Bye]
valley has quit [Remote host closed the connection]
BazzaBazaa has joined #ruby
jhass has joined #ruby
jhass[m] has left #ruby [#ruby]
jhass has quit [Remote host closed the connection]
jhass has joined #ruby
BazzaBazaa has quit [Remote host closed the connection]
BazzaBazaa has joined #ruby
<adam12>
nona: IMHO, avoid inline rescue.
markong has quit [Ping timeout: 252 seconds]
BazzaBazaa has quit [Remote host closed the connection]
momo- has quit [Ping timeout: 250 seconds]
sagax has joined #ruby
<sagax>
hi all
<Sobinec>
Hi, @sagax
<sagax>
how to convert string to hexcode? example, when i puts some string, i see in stdout not only hexcode
<ox1eef_>
It is not something I would use in a production environment but for quick hacks.
<nona>
and .call and -> go together?
<adam12>
nona: lambda/proc's have #call method. So we need to invoke the .call method.
<nona>
sadly, ox1eef_, this is most certainly production...
<adam12>
nona: There's shorthands that could work here but they are not as elegant, imho. try.() { current_baz }. try[] { current_baz }
<adam12>
the later is only on newer Ruby versions, IIRC.
<nona>
oh that looks cool tho
<nona>
unfortunately i'm stuck on 2.7 for now
<adam12>
I'd probably extract method in production code with a better name.
<nona>
oooh, the brackets only substitute `call`
<adam12>
And drop the proc in favour of the method.
<nona>
i understood some of those words
<nona>
proc being the {} behind .call?
<adam12>
Well, presumably this would be in a class of some sort. GatherFoobars. You have some perform method that does the gathering.
<adam12>
I might have a private method that is `handle_failure` which does the same as my proc.
<adam12>
then `perform` could be `[handle_failure { current_foo }, handle_failure { current_bar }, ...]`.
<nona>
alas, it's not in a class but buried in 4 levels of modules
<adam12>
Classes all the things
<nona>
but what you describe should still work
<adam12>
Extract Class and Extract Method are some of the two best refactoring methods.
<adam12>
Do you have the Refactoring Ruby book? It's pretty decent.
<adam12>
Tho it's out of print so you'll need to hit up ebay/similar.
<nona>
i do think i have it as a pdf
<nona>
it's just that i'm not feeling confident enough with this codebase yet to improve things outside of a very local scope. like, rewrite a method ok, rewrite a module/class ... better wait until i've seen more of it.
<nona>
the lambda technique looks fine for now
<adam12>
Yeah. I'd focus on tests until you build up some confidence.
<adam12>
A lot of walking skeleton tests.
<nona>
hahah. tests. good one :)
<adam12>
LOL
<nona>
in all seriousness, there are some. just nowhere near full coverage.
<nona>
hmm, i never heard "walking skeleton test" before though.
<adam12>
I'd focus on outside in tests. Something that just treats it like a blackbox.
<adam12>
Looks similar enough. Basically, start the application, automate tests somehow, then shut down the application. At least that's my memory of it.
<adam12>
Cover all the happy paths, then you can start slowly refactoring or adding more tests.
<adam12>
It's been a while since I read the book...
<nona>
i'll talk about that with my boss
<nona>
the problem is that the customer's management doesn't allow them even to fix bugs ... they want them to focus on new features
<adam12>
People start with unit testing which can work but sometimes you don't have enough knowledge about.
<ox1eef_>
That's a recipe for disaster.
<adam12>
Tho there is a guilded rose video that does mutation testing + unit testing and it looked super interesting. I'd love to try it.
<adam12>
Yeah, that's bad management. Like buying a car but never servicing it.
<nona>
yeah ox1eef_ the development team know about it. and they have a really cool scrum master, who's trying to shield them from management's weirdnesses and do deals, like "ok, we'll do feature x without complaining about it, but then you'll have to allow us a bugweek first".
<adam12>
I spend most of my time consulting, so the "no bug fixes" is something I do see fairly often. But generally I find management just doesn't want a huge rewrite of features.
<nona>
oh wow, Emily Bach seems cool
<adam12>
I ship a ton of refactorings every week. I'm pretty sure even in the Refactoring Ruby book, they call out that you should always be refactoring.
<adam12>
For me, sometimes refactoring is a bug fix :)
<nona>
so i'll aspire to be like you :)
<adam12>
LOL. If you ship features + bugs, nobody cares.
<adam12>
s/bugs/bug fixes
<nona>
so far i've been doing a lot of what i've learned is known as "boyscouting" and its been appreciated
<adam12>
but if you only ship refactoring / bug fixes, it's where people start to complain about lack of forward direction.
<ox1eef_>
On the other hand, it is important to deliver value and not focus entirely on engineering that doesn't reflect in end user experience.
<nona>
hmm ok so it's about balance
<ox1eef_>
Yep
<adam12>
Just cite Kent Beck. For each desired change, make the change easy (warning: this may be hard), then make the easy change.
<adam12>
If I'm tasked to ship a feature, I generally won't just drop it on top because it's likely a poor fit. I might insert a few seams or break up a very large class before doing the feature work.
<adam12>
Anyways, speaking of work. Good luck!
<nona>
you too! :)
<ox1eef_>
Have a good one
<nona>
and you, ox1eef_
<ox1eef_>
Cheers
konsolebox has quit [Quit: Leaving]
eddof13 has joined #ruby
krk85 has joined #ruby
krk85 has quit [Client Quit]
BazzaBazaa has quit [Remote host closed the connection]
_ht has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
eddof13 has joined #ruby
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
___nick___ has joined #ruby
Sankalp has quit [Ping timeout: 245 seconds]
graywolf has joined #ruby
Sankalp has joined #ruby
teclator has quit [Ping timeout: 260 seconds]
highs78 has joined #ruby
konsolebox has joined #ruby
eddof13 has joined #ruby
markong has quit [Ping timeout: 260 seconds]
Sampersand has joined #ruby
<Sampersand>
Hi all! Question about rspec: Is there a way to have toplevel `before`s run _AFTER_ `before`s defined in children `context`s?
eddof13 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
gabrielcsf has quit [Remote host closed the connection]
konsolebox has quit [Ping timeout: 240 seconds]
<ox1eef_>
Sampersand: they're run in the order they're defined.
<Sampersand>
darn, ok
konsolebox has joined #ruby
TomyLobo2 has quit [Remote host closed the connection]
mbarbar has quit [Ping timeout: 240 seconds]
mbarbar has joined #ruby
teclator has joined #ruby
Sampersand has quit [Quit: Client closed]
smp has quit [Ping timeout: 245 seconds]
smp has joined #ruby
octobear has quit [Remote host closed the connection]
eddof13 has joined #ruby
highs78 has quit [Remote host closed the connection]
foggin has joined #ruby
Linux_Kerio has quit [Ping timeout: 260 seconds]
infernix has quit [Remote host closed the connection]