Mailinglist Archive: opensuse-storage (4 mails)

< Previous Next >
[opensuse-storage] Sizes in yast-storage-ng after introducing alignment in libstorage-ng
Before
======

Before introducing alignment calculation in libstorage-ng the library
provided methods like

::Storage::Partition#size_k #=> Fixnum
::Storage::Disk#size_k #= Fixnum

On top of that, there was a DiskSize class with offered several
convenient methods including

DiskSize#size_k #=> Fixnum

And, on top of that we had many methods always called #size that
returned a DiskSize object, like

FreeDiskSpace#size #=> DiskSize
::Storage::Partition#size #=> DiskSize (using a refinement)

The API was pretty clear, you could always expect any method called
#size to return a DiskSize object and you always had #size_k to get a
Fixnum.

After
=====

All that beauty was broken with the change introduced in libstorage-ng.
Now its API looks like

::Storage::Partition#size #=> Fixnum (bytes)
::Storage::Disk#size #= Fixnum (bytes)

Now you cannot longer infer the type based in the name and everything
becomes more confusing with methods like

DiskSize#size #=> Fixnum (bytes)
DiskSize#size_b #=> Fixnum (alias for the former)
FreeDiskSpace#size #=> DiskSize

Solution 1
==========

We could rename all the methods from libstorage from #size to #size_b
and thus recover the initial consistency.

Solution 2
==========

We could rename all the methods in the ruby layer that return a DiskSize
object to something like #disk_size. So #size is always a Fixnum (bytes)
and #disk_size is always a DiskSize object. For example

FreeDiskSpace#disk_size #=> DiskSize

In addition, I would add DiskSize#bytes as a more readable alias for
DiskSize#size, resulting in things like this:

a_free_space.disk_size.bytes

What do you think?

--
Ancor González Sosa
YaST Team at SUSE Linux GmbH
--
To unsubscribe, e-mail: opensuse-storage+unsubscribe@xxxxxxxxxxxx
To contact the owner, e-mail: opensuse-storage+owner@xxxxxxxxxxxx

< Previous Next >
List Navigation