On Fri, Feb 24, 2017 at 01:51:42PM +0100, Josef Reidinger wrote:

> Let see how it will work in reality in bootloader code with storage-ng.
> 
> now:
> 
> def with_btrfs?(partition)
>   partition.filesystem.type == ::Storage::FsType_BTRFS
> rescue Storage::WrongNumberOfChildren, Storage::DeviceHasWrongType
>   # No filesystem in the partition
>   false
> end
> 
> can be:
> 
> def with_btrfs?(partition)
>   partition.filesystem.type.btrfs?
> end

Or can be:

def with_btrfs?(partition)
  partition.has_filesystem && is_btrfs(partition.filesystem)
end

No exceptions, no NullObject, no enum, no type classes. For me
straightforward readable code.

As I already wrote: The style is up to you.

ciao Arvin

-- 
Arvin Schnell, <[email protected]>
Senior Software Engineer, Research & Development
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 
(AG Nürnberg)
Maxfeldstraße 5
90409 Nürnberg
Germany
-- 
To unsubscribe, e-mail: [email protected]
To contact the owner, e-mail: [email protected]

Reply via email to