Re: [Vala] Use defined pathes inside a method



Hi Al, hi list,

On 06.05.2017 17:39, Al Thomas via vala-list wrote:
So you could have a FilePathsForSaving and a AuthorContactDetails interface
that are both implemented by your configuration object. When you come to
use them you only need a subset of the configuration object. So you could
have a method:
void save_my_work (Work work_object, FilePathsForSaving my_big_configuration_object) {...}
So i have prepared two interface classes [1] and [2].

The advantage is that each method only needs a subset of the data and it
means you can feed alternative objects in, so long as they implement the
same interface. That could be useful for testing individual components of 
your application. So if you want to write a test of the save_my_work() command
then you can feed in paths in a temporary directory and check the relevant data
is saved without having to construct a whole configuration object, just the FilePathsForSaving.
In general i planned to just get the data from the interfaces, not to
set it. The GSettings i would like to set with dconf, and the file
pathes are fixed and don't need to change it.

you could have:
public AuthorContactDetails author_contact_details;
and then the AuthorContactDetails object has properties for the name, etc.
I have used it so [3]. As far as i understand, i get now the contents
from both classes and the properties are connected with them. Or?

What are the next steps. Should the Configuration object now inherit
from AuthorDetails and FilePathes? Or should each new class, who needs
stuff from a interface inherit from a interface like "public class New :
AuthorDetails"?

Greetings
Sascha


[1]
https://github.com/saigkill/gnome-publisher/blob/master/src/core/author.details.vala
[2]
https://github.com/saigkill/gnome-publisher/blob/master/src/core/filepathes.vala
[3]
https://github.com/saigkill/gnome-publisher/blob/master/src/core/create_publication_core.vala
-- 
Sascha Manns
Maifeldstraße 10
56727 Mayen

P: +49-2651-4014045
W: http://saigkill.tuxfamily.org


Attachment: signature.asc
Description: OpenPGP digital signature



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