psycharo-zz / factor-graph

matlab/c++ factor graph framework
32 stars 8 forks source link

feedback on gaussMessage() #42

Closed ghost closed 11 years ago

ghost commented 11 years ago

Do you agree with the folowing?

As a user, I look at the +ffg folder to get an overview of my interface (API) to this toolbox. I then find gaussMessage(), gaussVarianceMessage() and gaussPrecisionMessage() a bit too cloudy and it bodes for more functions as we extend the toolbox.

How about this:

Replace those 3 functions by a function setMessage(), as follows:

function msg = setMessage(type,varargin)
%SETMESSAGE sets messages
%
% syntax: msg = setMessage(type,varargin)
%
% type       - message type, any of {'gauss', ...}
% varargin - type-dependent name-value parameter pairs 
% msg       -  message struct
% 
% examples:
%   msg = setMessage('gauss','mean',2,'variance',3); 
%   msg = setMessage('gauss','mean',2,'precision',1/3); 
%

This would provide a single interface to setting messages; the interface is easily readable and extensible. If necessary, the functions gaussMessage(), gaussVarianceMessage() and gaussPrecisionMessage() could be subfunctions in setMessage()

If you agree, please implement

psycharo-zz commented 11 years ago

I would say that having a separate function for a separate message type is the way to go. I was planning to remove gaussMessage()

psycharo-zz commented 11 years ago

now for every message there is a special method to create it. they all should be in +ffg/+messages. called as follows: ffg.messages.gaussVariance([0 1], [1 0; 0 1])