grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Set size of partition correctly in grub_disk_open()


From: Yoshinori K. Okuji
Subject: Re: [PATCH] Set size of partition correctly in grub_disk_open()
Date: Sun, 9 Jul 2006 15:29:17 +0200
User-agent: KMail/1.8.2

On Sunday 09 July 2006 14:01, Jeroen Dekkers wrote:
> I don't see anything like that in the code when I grep for
> total_sectors. The only code that is using total_sectors as the size
> of the disk is the grub_disk_check_range(), but that function is also
> interested in whether the offset/size fits in the partition when
> reading from a partition. If total_sectors was the size of the
> partition, the two ifs in grub_disk_check_range() could be merged to
> just one if for both cases.

Probably the idea was only in my mind. There are so many things that are not 
implemented yet!

> Well, both users of total_sectors are assuming the semantics I'm
> proposing, which only reinforces my point that it's the more logical
> thing to do.

No. I don't think we can agree on this, since you don't see my point.

GRUB is based on an object-oriented design. In object-oriented programming, 
how attributes are stored is an implementation detail, so attributes should 
not be accessed directly from the outside. On the other hand, it is sometimes 
more convenient or just faster to access attributes directly. In this sense, 
the current code in GRUB is a mixture.

However, my wish is to enforce the object-oriented paradigm as much as 
possible. What should the disk structure store as information? Of course, 
about the disk itself. What should the partition structure as information? Of 
course, about the partition itself. What should total_sectors store? Of 
course, about the disk, since it is a part of the disk structure. Is it 
inconvenient? Then, define an accessor appropriately.

Your proposal simply breaks the rule of object-encapsulation in 
object-oriented programming, so I never agree with you about this.

BTW, that's why I recommend studying ruby to understand GRUB better. You can 
learn similar things with python, c++, php, etc., but there are very few 
languages with pure object-orientation. For example, python programmers tend 
to access attributes in an object directly from time to time, because the 
language is not very strict. In ruby, accessors are obligatory.

If you don't still agree with me, it's the end of the discussion.

Okuji




reply via email to

[Prev in Thread] Current Thread [Next in Thread]